final PhoneBook modifiedPhoneBook = PhoneBook.from(phoneBook);
modifiedPhoneBook.getContact("Jesse", "Pinkman").setMiddleName("Bruce");
modifiedPhoneBook.getContact("Walter", "White").setMiddleName("Hartwell");
final ObjectDiffer objectDiffer = ObjectDifferBuilder.buildDefault();
final DiffNode node = objectDiffer.compare(modifiedPhoneBook, phoneBook);
assertThat(node.hasChanges(), is(true));
assertThat(node.hasChildren(), is(true));
assertThat(node.childCount(), is(1));
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());
assertThat((String) whiteMiddleNameNode.canonicalGet(modifiedPhoneBook), IsEqual.equalTo("Hartwell"));
}