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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations