Skip to content

Including a "Collection" attribute in the Configuration #70

@gulench

Description

@gulench

How do you set up a Configuration that includes a "Collection" attribute? Please refer the test code snippet shown below; I'm not able to make it work.

On the other hand, Configuration.withoutProperty works with the PropertyPath aliases.

Object class to compare:

public class Person { private String name; private List<String> aliases; public Person() { } public Person(String name, List<String> aliases) { this.name = name; this.aliases = aliases; this.addresses = addresses; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public List<String> getAliases() { return this.aliases; } public void setAliases(List<String> aliases) { this.aliases = aliases; }

Test class:

@RunWith(JUnit4.class) public class Test { @Test public void testIncludeCollectionAttribute() { Person a = new Person( "Gulen Chongtham", Arrays.asList(new String[] {"Hola Espanyol", "Vicky Boss"}) ); Person b = new Person( "Gulen Chongthamm", Arrays.asList(new String[] {"Hola Espanyol", "Vicky Boss", "Roger Harper"}) ); ObjectDiffer differ = ObjectDifferFactory.getInstance( new Configuration() .withPropertyPath(PropertyPath.buildWith("aliases")) ); Node root = differ.compare(b, a); root.visit(new PrintingVisitor(b, a)); assertTrue(root.isChanged()); } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions