示例#1
0
  @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);
  }
示例#2
0
  @Test
  public void shouldPutAllElements() {
    // given
    SmallMap<String, Integer> smallTestMap = smallTestMap();
    SmallMap<String, Integer> newSmallMap = SmallMap.newSmallMap();

    // when
    newSmallMap.putAll(smallTestMap);

    // then
    assertThat(newSmallMap).isEqualTo(smallTestMap);
    assertThat(smallTestMap).isEqualTo(newSmallMap);
  }