Package de.danielbechler.diff.selector

Examples of de.danielbechler.diff.selector.CollectionItemElementSelector


    baseAddressBook.setContacts(asList(baseContact));

    final DiffNode rootNode = ObjectDifferBuilder.buildDefault()
        .compare(workingAddressBook, baseAddressBook);
    final DiffNode contactsNode = rootNode.getChild("contacts");
    final DiffNode contactNode = contactsNode.getChild(new CollectionItemElementSelector(baseContact));
    final DiffNode nicknameNode = contactNode.getChild("nickname");

    rootNode.visit(new NodeHierarchyVisitor());

    /*
 
View Full Code Here


    final DiffNode contactsNode = node.getChild("contacts");
    assertThat(contactsNode, IsNull.notNullValue());
    assertThat(contactsNode.hasChanges(), is(true));

    final DiffNode pinkmanNode = contactsNode.getChild(new CollectionItemElementSelector(jessePinkman));
    assertThat(pinkmanNode.hasChanges(), is(true));

    final DiffNode middleNameNode = pinkmanNode.getChild("middleName");
    assertThat(middleNameNode.hasChanges(), is(true));
    assertThat(middleNameNode.canonicalGet(phoneBook), IsNull.nullValue());
    assertThat((String) middleNameNode.canonicalGet(modifiedPhoneBook), IsEqual.equalTo("Bruce"));

    final DiffNode whiteNode = contactsNode.getChild(new CollectionItemElementSelector(walterWhite));
    assertThat(whiteNode.hasChanges(), is(true));

    final DiffNode whiteMiddleNameNode = whiteNode.getChild("middleName");
    assertThat(whiteMiddleNameNode.hasChanges(), is(true));
    assertThat(whiteMiddleNameNode.canonicalGet(phoneBook), IsNull.nullValue());
View Full Code Here

    final Collection<String> base = new LinkedList<String>();

    final DiffNode node = ObjectDifferBuilder.buildDefault().compare(working, base);

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.CHANGED);
    NodeAssertions.assertThat(node).child(new CollectionItemElementSelector("foo")).hasState(DiffNode.State.ADDED);
  }
View Full Code Here

    final Collection<String> base = new LinkedList<String>(asList("foo"));

    final DiffNode node = ObjectDifferBuilder.buildDefault().compare(working, base);

    NodeAssertions.assertThat(node).self().hasState(DiffNode.State.CHANGED);
    NodeAssertions.assertThat(node).child(new CollectionItemElementSelector("foo")).hasState(DiffNode.State.REMOVED);
  }
View Full Code Here

    final List<?> base = asList(new ObjectWithIdentityAndValue("foo", "2"));

    final DiffNode node = ObjectDifferBuilder.buildDefault().compare(working, base);

    assertThat(node).self().hasChanges();
    assertThat(node).child(new CollectionItemElementSelector(new ObjectWithIdentityAndValue("foo")))
        .hasState(DiffNode.State.CHANGED);
  }
View Full Code Here

  }

  @Test
  public void testWithElement()
  {
    final CollectionItemElementSelector element = new CollectionItemElementSelector("foo");
    final NodePath nodePath = NodePath.startBuilding().element(element).build();
    assertThat(nodePath.getElementSelectors()).containsSequence(
        RootElementSelector.getInstance(),
        element);
  }
View Full Code Here

  @Test
  public void testWithCollectionItem()
  {
    final NodePath nodePath = NodePath.startBuilding().collectionItem("foo").build();
    assertThat(nodePath.getElementSelectors()).containsSequence(RootElementSelector.getInstance(), new CollectionItemElementSelector("foo"));
  }
View Full Code Here

  }

  @Test
  public void return_proper_path_element()
  {
    final CollectionItemElementSelector expectedPathElement = new CollectionItemElementSelector(referenceItem);

    final ElementSelector actualPathElementSelector = accessor.getElementSelector();

    assertThat(actualPathElementSelector).isEqualTo(expectedPathElement);
  }
View Full Code Here

    throw new IllegalArgumentException(object.getClass().toString());
  }

  public ElementSelector getElementSelector()
  {
    return new CollectionItemElementSelector(referenceItem);
  }
View Full Code Here

      return child(NodePath.startBuilding().element(pathElementSelector));
    }

    public Syntax.AssertNode collectionChild(final Object referenceItem)
    {
      return child(new CollectionItemElementSelector(referenceItem));
    }
View Full Code Here

TOP

Related Classes of de.danielbechler.diff.selector.CollectionItemElementSelector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.