Search in sources :

Example 71 with Node

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);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) TreeTestSupport.featureNode(org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 72 with Node

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);
}
Also used : Node(org.locationtech.geogig.api.Node) RevTree(org.locationtech.geogig.api.RevTree)

Example 73 with Node

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());
}
Also used : Node(org.locationtech.geogig.api.Node)

Example 74 with Node

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());
}
Also used : Node(org.locationtech.geogig.api.Node) Test(org.junit.Test)

Example 75 with Node

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);
}
Also used : Node(org.locationtech.geogig.api.Node) TreeTestSupport.featureNode(org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Aggregations

Node (org.locationtech.geogig.api.Node)117 RevTree (org.locationtech.geogig.api.RevTree)56 Test (org.junit.Test)50 ObjectId (org.locationtech.geogig.api.ObjectId)44 NodeRef (org.locationtech.geogig.api.NodeRef)24 Bucket (org.locationtech.geogig.api.Bucket)20 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)18 Envelope (com.vividsolutions.jts.geom.Envelope)16 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)14 RevCommit (org.locationtech.geogig.api.RevCommit)10 Map (java.util.Map)9 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)9 Patch (org.locationtech.geogig.api.plumbing.diff.Patch)9 File (java.io.File)7 RevFeature (org.locationtech.geogig.api.RevFeature)7 WorkingTree (org.locationtech.geogig.repository.WorkingTree)7 Feature (org.opengis.feature.Feature)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 Stopwatch (com.google.common.base.Stopwatch)6 SortedMap (java.util.SortedMap)5