예제 #1
0
  @Test
  public void shouldClearMap() {
    // given
    SmallMap<String, Integer> smallTestMap = smallTestMap();
    assertThat(smallTestMap.isEmpty()).isFalse();

    // when
    smallTestMap.clear();

    // then
    assertThat(smallTestMap.isEmpty()).isTrue();
    assertThat(smallTestMap.size()).isZero();
  }
예제 #2
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);
  }
예제 #3
0
  @Test
  public void emptyMapShouldBeEmpty() {
    // given
    SmallMap<Object, Object> newSmallMap = SmallMap.newSmallMap();

    // when
    boolean empty = newSmallMap.isEmpty();
    int size = newSmallMap.size();

    // then
    assertThat(empty).isTrue();
    assertThat(size).isZero();
  }