Skip to content

Commit

Permalink
Merge pull request #1219 from mockito/regression-test-1174
Browse files Browse the repository at this point in the history
Add regression test for issue #1174
  • Loading branch information
mockitoguy committed Oct 29, 2017
2 parents ca2a246 + 9f5312b commit c2d8f02
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.mockitousage.bugs;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

import java.util.ArrayList;
import java.util.Collection;

import static org.mockito.BDDMockito.given;
import static org.mockito.MockitoAnnotations.initMocks;

/**
* This was an issue reported in #1174.
*/
public class GenericsMockitoAnnotationsTest {

@Mock
private TestCollectionSourceProvider testCollectionSourceProvider;

@Test
public void should_not_throw_class_cast_exception() {
given(testCollectionSourceProvider.getCollection(new ArrayList<Integer>())).willReturn(new ArrayList<Integer>());
}

static class TestCollectionSourceProvider {
<T extends Collection<E>, E> T getCollection(T collection) {
return collection;
}
}

@Before
public void setUp() throws Exception {
initMocks(this);
}
}

0 comments on commit c2d8f02

Please sign in to comment.