}
@Test
public void getChildrenShouldReturnTheDistinctChildrenOfAParent() {
// Given a tree path has 3 children, 2 of which are equal:
TreePath branch = new TreePath(new Object[]{0, 1});
TreePath leaf1 = branch.createChildPath(2);
TreePath leaf2 = branch.createChildPath(3);
TreePath leaf3 = branch.createChildPath(3);
Object input = new Object();
ITreePathBuilder builder = mock(ITreePathBuilder.class);
given(builder.build(input)).willReturn(asList(leaf1, leaf2, leaf3));
content = create(builder);
// When asking for the children of the parent path:
content.inputChanged(null, null, input); // Sets the input.
List<Object> children = newArrayList(content.getChildren(branch));
// Then the distinct children should be returned:
List<Object> expected = newArrayList(newHashSet( // Get unique children
leaf1.getLastSegment(),
leaf2.getLastSegment(),
leaf3.getLastSegment()));
assertThat(children, is(equalTo(expected)));
}