use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class PreOrderDiffWalkTest method testSkipRemovedTree.
@Test
public void testSkipRemovedTree() {
// two leaf trees
ObjectId metadataId = ObjectId.forString("fake");
RevTree left = createTreesTree(leftSource, 3, 10, metadataId).build();
RevTree right = createTreesTree(rightSource, 2, 10, metadataId).build();
PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
final Node lroot = nodeFor(left);
final Node rroot = nodeFor(right);
// consume the root tree
when(consumer.tree(eq(lroot), eq(rroot))).thenReturn(true);
// but skip the removed tree
when(consumer.tree(any(Node.class), (Node) isNull())).thenReturn(false);
visitor.walk(consumer);
// one call to tree() for the root tree, and another for the removed subtree
verify(consumer, times(2)).tree(any(Node.class), any(Node.class));
// but no calls to feature() as we returned false on the second call to tree()
verify(consumer, times(0)).feature(any(Node.class), any(Node.class));
verify(consumer, times(2)).endTree(any(Node.class), any(Node.class));
verifyNoMoreInteractions(consumer);
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class DiffCountConsumerTest method createFeatureTypesTree.
private void createFeatureTypesTree(RevTreeBuilder rootBuilder, String treePath, RevTreeBuilder childBuilder) {
RevTree childTree = childBuilder.build();
odb.put(childTree);
Node childRef = Node.create(treePath, childTree.getId(), ObjectId.NULL, TYPE.TREE, null);
rootBuilder.put(childRef);
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class MutableTreeTest method assertNode.
private void assertNode(MutableTree mutableTree, ObjectId treeId, @Nullable ObjectId metadtaId, String nodeName) {
assertNotNull(mutableTree);
Node node = mutableTree.getNode();
assertNotNull(node);
assertEquals(treeId, node.getObjectId());
if (metadtaId == null) {
assertFalse(node.getMetadataId().isPresent());
} else {
assertEquals(metadtaId, node.getMetadataId().get());
}
assertEquals(nodeName, node.getName());
assertEquals(TYPE.TREE, node.getType());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class MutableTreeTest method testSet.
@Test
public void testSet() {
Node node = treeNode("roads", id("a11"), id("d1"));
root.setChild("", node);
assertEquals(node, root.getChild("roads").getNode());
node = treeNode("stores", id("a51"), id("d3"));
root.setChild("buildings", node);
assertEquals(node, root.getChild("buildings/stores").getNode());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class PreOrderDiffWalkTest method testLeafLeafTwoAdds.
@Test
public void testLeafLeafTwoAdds() {
// two leaf trees
RevTree left = createFeaturesTree(leftSource, "f", 3).build();
RevTree right = createFeaturesTree(rightSource, "f", 5).build();
PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
final Node lroot = nodeFor(left);
final Node rroot = nodeFor(right);
when(consumer.tree(eq(lroot), eq(rroot))).thenReturn(true);
visitor.walk(consumer);
verify(consumer, times(1)).tree(eq(lroot), eq(rroot));
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());
assertNull(larg.getAllValues().get(0));
assertNull(larg.getAllValues().get(1));
// the two added nodes
Node n1 = featureNode("f", 3);
Node n2 = featureNode("f", 4);
assertTrue(rarg.getAllValues().contains(n1));
assertTrue(rarg.getAllValues().contains(n2));
verify(consumer, times(1)).endTree(eq(lroot), eq(rroot));
verifyNoMoreInteractions(consumer);
}
Aggregations