Skip to content

Commit

Permalink
mockito#2921: test nested type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Jörg von Frantzius committed Feb 27, 2023
1 parent 19f088c commit c9363cb
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

Expand All @@ -26,6 +28,7 @@ public static class UnderTest {
List<String> stringList;
List<Integer> intList;
Set<?> anySet;
Map<Integer, ? extends Collection<String>> intStringCollectionMap;
}

@Mock
Expand All @@ -35,7 +38,10 @@ public static class UnderTest {
private List<Integer> intProviderMock;

@Mock
private TreeSet<String> treeSet = Mockito.mock(TreeSet.class);;
private TreeSet<String> treeSetMock = Mockito.mock(TreeSet.class);;

@Mock
private Map<Integer, List<String>> intStringListMapMock;

@InjectMocks
private UnderTest underTest;
Expand All @@ -52,11 +58,12 @@ public void testInjectMock() {
assertNotNull(underTest.stringList);
assertNotNull(underTest.intList);
assertNotNull(underTest.anySet);
assertNotNull(underTest.intStringCollectionMap);

assertEquals(stringProviderMock, underTest.stringList);
assertEquals(intProviderMock, underTest.intList);
assertEquals(treeSet, underTest.anySet);

assertEquals(treeSetMock, underTest.anySet);
assertEquals(intStringListMapMock, underTest.intStringCollectionMap);
}

}

0 comments on commit c9363cb

Please sign in to comment.