@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 shouldReturnEntrySet() { // given SmallMap<String, Integer> newSmallMap = SmallMap.newSmallMap(3); newSmallMap.put("abc", 123); newSmallMap.put("def", 456); // when Set<Entry<String, Integer>> entrySet = newSmallMap.entrySet(); // then assertThat(entrySet) .containsOnly( new MyEntry<String, Integer>("abc", 123), new MyEntry<String, Integer>("def", 456)); }