Search in sources :

Example 66 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class PostOrderDiffWalkTest method testBucketBucketFlat.

@Test
public void testBucketBucketFlat() {
    RevTree left = createFeaturesTree(leftSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 1).build();
    RevTree right = createFeaturesTree(rightSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 2).build();
    PostOrderDiffWalk visitor = new PostOrderDiffWalk(left, right, leftSource, rightSource);
    visitor.walk(testConsumer);
    List<Bounded> leftCalls = testConsumer.orderedLeft;
    List<Bounded> rightCalls = testConsumer.orderedRight;
    // System.err.println(leftCalls);
    // System.err.println(rightCalls);
    Node lroot = nodeFor(left);
    Node rroot = nodeFor(right);
    assertEquals(3, leftCalls.size());
    assertEquals(3, rightCalls.size());
    assertNull(leftCalls.get(0));
    assertTrue(leftCalls.get(1) instanceof Bucket);
    assertEquals(lroot, leftCalls.get(2));
    assertEquals(rroot, rightCalls.get(2));
    assertTrue(rightCalls.get(1) instanceof Bucket);
    assertTrue(rightCalls.get(0) instanceof Node);
    assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(0)).getType());
}
Also used : Bounded(org.locationtech.geogig.api.Bounded) Bucket(org.locationtech.geogig.api.Bucket) 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 67 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class PreOrderDiffWalkTest method testBucketLeafSimple.

@Test
public void testBucketLeafSimple() {
    final int leftsize = 1 + RevTree.NORMALIZED_SIZE_LIMIT;
    RevTree left = createFeaturesTree(leftSource, "f", leftsize).build();
    RevTree right = createFeaturesTree(rightSource, "f", 1).build();
    PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
    // consume all
    when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(true);
    when(consumer.bucket(anyInt(), anyInt(), any(Bucket.class), any(Bucket.class))).thenReturn(true);
    visitor.walk(consumer);
    // there's only the root tree
    verify(consumer, times(1)).tree(any(Node.class), any(Node.class));
    // there's only one feature on the right tree, so all right trees features fall on a single
    // bucket
    final int leftBucketCount = left.buckets().get().size();
    final int expectedBucketCalls = leftBucketCount - 1;
    verify(consumer, times(expectedBucketCalls)).bucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verify(consumer, times(leftsize - 1)).feature(any(Node.class), (Node) isNull());
    verify(consumer, times(expectedBucketCalls)).endBucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verify(consumer, times(1)).endTree(any(Node.class), any(Node.class));
    verifyNoMoreInteractions(consumer);
}
Also used : Bucket(org.locationtech.geogig.api.Bucket) 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 68 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class PreOrderDiffWalkTest method testLeafLeafChanged.

@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());
    // the two added nodes
    Node n1 = featureNode("f", 2);
    Node n2 = featureNode("f", 3);
    assertTrue(larg.getAllValues().contains(n1));
    assertTrue(larg.getAllValues().contains(n2));
    assertTrue(rarg.getAllValues().contains(nodeChange1));
    assertTrue(rarg.getAllValues().contains(nodeChange2));
    verify(consumer, times(1)).endTree(any(Node.class), any(Node.class));
    verifyNoMoreInteractions(consumer);
}
Also used : Node(org.locationtech.geogig.api.Node) TreeTestSupport.featureNode(org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 69 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class PreOrderDiffWalkTest method testCallsRootNode.

@Test
public void testCallsRootNode() {
    RevTree left = createFeaturesTree(leftSource, "f", 1).build();
    RevTree right = createFeaturesTree(rightSource, "f", 2).build();
    PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
    visitor.walk(consumer);
    when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(false);
    final Node lNode = nodeFor(left);
    final Node rNode = nodeFor(right);
    ArgumentCaptor<Node> leftNode = ArgumentCaptor.forClass(Node.class);
    ArgumentCaptor<Node> rightNode = ArgumentCaptor.forClass(Node.class);
    verify(consumer, times(1)).tree(leftNode.capture(), rightNode.capture());
    assertEquals(lNode, leftNode.getValue());
    assertEquals(rNode, rightNode.getValue());
    verify(consumer, times(1)).endTree(leftNode.capture(), rightNode.capture());
    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)

Example 70 with Node

use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.

the class PreOrderDiffWalkTest method testBucketBucketFlat.

@Test
public void testBucketBucketFlat() {
    RevTree left = createFeaturesTree(leftSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 1).build();
    RevTree right = createFeaturesTree(rightSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 2).build();
    PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
    when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(true);
    when(consumer.bucket(anyInt(), anyInt(), any(Bucket.class), any(Bucket.class))).thenReturn(true);
    visitor.walk(consumer);
    verify(consumer, times(1)).tree(any(Node.class), any(Node.class));
    verify(consumer, times(1)).bucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verify(consumer, times(1)).feature((Node) isNull(), any(Node.class));
    verify(consumer, times(1)).endTree(any(Node.class), any(Node.class));
    verify(consumer, times(1)).endBucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verifyNoMoreInteractions(consumer);
}
Also used : Bucket(org.locationtech.geogig.api.Bucket) 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