Esempio n. 1
0
  @Test
  public void node_property_should_be_deleted() {
    NodeImpl node = new NodeImpl();
    Map<String, String> properties = new LinkedHashMap<>();
    properties.put("prop1", "val1");
    properties.put("prop2", "val2");
    properties.put("prop3", "val3");
    node.setProperties(properties);

    PropertyChange propertyChange = new PropertyChange("prop2"::equals, t -> null);

    propertyChange.consume(node);

    Map<String, String> newProperties = node.getProperties();
    assertThat(newProperties.size(), is(2));
    Iterator<Map.Entry<String, String>> propIter = newProperties.entrySet().iterator();

    Map.Entry<String, String> currentEntry = propIter.next();
    assertThat(currentEntry.getKey(), is(equalTo("prop1")));
    assertThat(currentEntry.getValue(), is(equalTo("val1")));

    currentEntry = propIter.next();
    assertThat(currentEntry.getKey(), is(equalTo("prop3")));
    assertThat(currentEntry.getValue(), is(equalTo("val3")));

    assertFalse(propIter.hasNext());
  }
Esempio n. 2
0
  @Test
  public void revision_property_should_be_changed() {
    RevisionImpl revision = new RevisionImpl(2);
    Map<String, String> properties = new LinkedHashMap<>();
    properties.put("prop1", "val1");
    properties.put("prop2", "val2");
    properties.put("prop3", "val3");
    revision.setProperties(properties);

    PropertyChange propertyChange = new PropertyChange("prop2"::equals, t -> "d");

    propertyChange.consume(revision);

    Map<String, String> newProperties = revision.getProperties();
    assertThat(newProperties.size(), is(3));
    Iterator<Map.Entry<String, String>> propIter = newProperties.entrySet().iterator();

    Map.Entry<String, String> currentEntry = propIter.next();
    assertThat(currentEntry.getKey(), is(equalTo("prop1")));
    assertThat(currentEntry.getValue(), is(equalTo("val1")));

    currentEntry = propIter.next();
    assertThat(currentEntry.getKey(), is(equalTo("prop2")));
    assertThat(currentEntry.getValue(), is(equalTo("d")));

    currentEntry = propIter.next();
    assertThat(currentEntry.getKey(), is(equalTo("prop3")));
    assertThat(currentEntry.getValue(), is(equalTo("val3")));

    assertFalse(propIter.hasNext());
  }