@Test
public void testLeafLeafChanged() {
// two leaf trees
final RevTree left;
final RevTree right;
final Node nodeChange1 = Node.create("f2", ObjectId.forString("forcechange"),
ObjectId.NULL, TYPE.FEATURE, null);
final Node nodeChange2 = Node.create("f3", ObjectId.forString("fakefake"), ObjectId.NULL,
TYPE.FEATURE, null);
{
left = createFeaturesTree(leftSource, "f", 5).build();
// change two nodes
RevTreeBuilder builder = createFeaturesTree(rightSource, "f", 5);
builder.put(nodeChange1);
builder.put(nodeChange2);
right = builder.build();
}
PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(true);
visitor.walk(consumer);
// call of the root tree nodes
verify(consumer, times(1)).tree(any(Node.class), any(Node.class));
ArgumentCaptor<Node> larg = ArgumentCaptor.forClass(Node.class);
ArgumentCaptor<Node> rarg = ArgumentCaptor.forClass(Node.class);
verify(consumer, times(2)).feature(larg.capture(), rarg.capture());
assertEquals(2, larg.getAllValues().size());
assertEquals(2, rarg.getAllValues().size());
Node n1 = featureNode("f", 2);// the two added nodes
Node n2 = featureNode("f", 3);
assertTrue(larg.getAllValues().contains(n1));
assertTrue(larg.getAllValues().contains(n2));
assertTrue(rarg.getAllValues().contains(nodeChange1));