Exemplo n.º 1
0
 @Test
 public void testRemoveObject1() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   map.put(literal(String.class, "key"), literal(String.class, "value"));
   assertThat(map.remove(literal(String.class, "string")), nullValue());
   assertThat(map.remove(literal(String.class, "key")), equalTo(literal(String.class, "value")));
 }
Exemplo n.º 2
0
  @Test
  public void testToString1() throws Exception {
    SerializedMap map = new SerializedMap(Map.class, HashMap.class);
    map.put(literal(String.class, "key"), literal(String.class, "value"));

    assertThat(map.toString(), equalTo("{key:value}"));
  }
Exemplo n.º 3
0
 @Test
 public void testContainsValue1() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   map.put(literal(String.class, "key"), literal(String.class, "value"));
   assertThat(map.containsValue(literal(String.class, "value")), is(true));
   assertThat(map.containsValue(literal(String.class, "string")), is(false));
 }
Exemplo n.º 4
0
  @Test
  public void testValues() throws Exception {
    SerializedMap map = new SerializedMap(Map.class, HashMap.class);
    map.put(literal(String.class, "key1"), literal(String.class, "value1"));
    map.put(literal(String.class, "key2"), literal(String.class, "value2"));

    assertThat(
        map.values(),
        containsInAnyOrder(literal(String.class, "value1"), literal(String.class, "value2")));
  }
Exemplo n.º 5
0
  @Test
  public void testClear() throws Exception {
    SerializedMap map = new SerializedMap(Map.class, HashMap.class);
    map.put(literal(String.class, "key1"), literal(String.class, "value1"));
    map.put(literal(String.class, "key2"), literal(String.class, "value2"));

    map.clear();

    assertThat(map.keySet(), empty());
  }
Exemplo n.º 6
0
  @Test
  public void testPutAll() throws Exception {
    SerializedMap map = new SerializedMap(Map.class, HashMap.class);
    Map<SerializedValue, SerializedValue> value = new HashMap<>();
    value.put(literal(String.class, "key1"), literal(String.class, "value1"));
    value.put(literal(String.class, "key2"), literal(String.class, "value2"));

    map.putAll(value);

    assertThat(map, hasEntry(literal(String.class, "key1"), literal(String.class, "value1")));
    assertThat(map, hasEntry(literal(String.class, "key2"), literal(String.class, "value2")));
  }
Exemplo n.º 7
0
 @Test
 public void testSize0() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   assertThat(map.size(), equalTo(0));
 }
Exemplo n.º 8
0
 @Test
 public void testAccept() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   assertThat(map.accept(new TestValueVisitor()), equalTo("unknown"));
   assertThat(map.accept(new TestCollectionVisitor()), equalTo("map"));
 }
Exemplo n.º 9
0
  @Test
  public void testToString0() throws Exception {
    SerializedMap map = new SerializedMap(Map.class, HashMap.class);

    assertThat(map.toString(), equalTo("{}"));
  }
Exemplo n.º 10
0
 @Test
 public void testRemoveObject0() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   assertThat(map.remove(literal(String.class, "string")), nullValue());
 }
Exemplo n.º 11
0
 @Test
 public void testIsEmpty1() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   map.put(literal(String.class, "key"), literal(String.class, "value"));
   assertThat(map.isEmpty(), is(false));
 }
Exemplo n.º 12
0
 @Test
 public void testIsEmpty0() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   assertThat(map.isEmpty(), is(true));
 }
Exemplo n.º 13
0
 @Test
 public void testSize1() throws Exception {
   SerializedMap map = new SerializedMap(Map.class, HashMap.class);
   map.put(literal(String.class, "key"), literal(String.class, "value"));
   assertThat(map.size(), equalTo(1));
 }