@Test public void shouldDelegateToCreatedMapWhenBig() { // given SmallMap<String, Integer> map2 = smallTestMap(); Map<String, Integer> mapMock = createMapMock(); SmallMap<String, Integer> smallMap = createSmallMap(mapMock); fillAndVerify(mapMock, smallMap); // when smallMap.put("abc", 123); Mockito.verify(mapMock).put("abc", 123); // when smallMap.containsKey("abc"); Mockito.verify(mapMock).containsKey("abc"); // when smallMap.containsValue(123); Mockito.verify(mapMock).containsValue(123); // when smallMap.entrySet(); Mockito.verify(mapMock).entrySet(); // when smallMap.values(); Mockito.verify(mapMock).values(); // when smallMap.keySet(); Mockito.verify(mapMock).keySet(); // when smallMap.get("abc"); Mockito.verify(mapMock).get("abc"); // when smallMap.isEmpty(); Mockito.verify(mapMock).isEmpty(); // when smallMap.size(); Mockito.verify(mapMock).size(); // when smallMap.putAll(map2); Mockito.verify(mapMock).putAll(map2); // when smallMap.remove("abc"); Mockito.verify(mapMock).remove("abc"); // then Mockito.verifyNoMoreInteractions(mapMock); }
@Test public void shouldReturnValuesCollection() { // given SmallMap<String, Integer> map1 = smallTestMap(); // when Collection<Integer> values = map1.values(); // then assertThat(values).containsOnly(123, 155, 456); }