use of org.locationtech.geogig.api.RevTreeBuilder 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.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DepthTreeIteratorTest method testRecursive.
@Test
public void testRecursive() {
assertEquals(0, list(emptyTree, Strategy.RECURSIVE).size());
assertEquals(100, list(featuresLeafTree, Strategy.RECURSIVE).size());
assertEquals(treesLeafTree.size() + treesLeafTree.numTrees(), list(treesLeafTree, Strategy.RECURSIVE).size());
assertEquals(mixedLeafTree.size() + mixedLeafTree.numTrees(), list(mixedLeafTree, Strategy.RECURSIVE).size());
assertEquals(featuresBucketsTree.size(), list(featuresBucketsTree, Strategy.RECURSIVE).size());
int numSubTrees = RevTree.NORMALIZED_SIZE_LIMIT + 1;
int featuresPerTree = RevTree.NORMALIZED_SIZE_LIMIT + 1;
RevTreeBuilder builder = createTreesTree(source, numSubTrees, featuresPerTree, metadataId);
for (int i = 0; i < 25000; i++) {
builder.put(featureNode("f", i));
}
RevTree mixedBucketsTree = builder.build();
assertEquals(mixedBucketsTree.size() + mixedBucketsTree.numTrees(), list(mixedBucketsTree, Strategy.RECURSIVE).size());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DepthTreeIteratorTest method testRecursiveFeaturesOnly.
@Test
public void testRecursiveFeaturesOnly() {
assertEquals(0, list(emptyTree, Strategy.RECURSIVE_FEATURES_ONLY).size());
assertEquals(100, list(featuresLeafTree, Strategy.RECURSIVE_FEATURES_ONLY).size());
assertEquals(treesLeafTree.size(), list(treesLeafTree, Strategy.RECURSIVE_FEATURES_ONLY).size());
assertEquals(mixedLeafTree.size(), list(mixedLeafTree, Strategy.RECURSIVE_FEATURES_ONLY).size());
assertEquals(featuresBucketsTree.size(), list(featuresBucketsTree, Strategy.RECURSIVE_FEATURES_ONLY).size());
int numSubTrees = RevTree.NORMALIZED_SIZE_LIMIT + 1;
int featuresPerTree = RevTree.NORMALIZED_SIZE_LIMIT + 1;
RevTreeBuilder builder = createTreesTree(source, numSubTrees, featuresPerTree, metadataId);
for (int i = 0; i < 25000; i++) {
builder.put(featureNode("f", i));
}
RevTree mixedBucketsTree = builder.build();
assertEquals(mixedBucketsTree.size(), list(mixedBucketsTree, Strategy.RECURSIVE_FEATURES_ONLY).size());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DepthTreeIteratorTest method setUp.
@Before
public void setUp() {
source = new HeapObjectDatabse();
source.open();
metadataId = ObjectId.forString("fake id");
treePath = "";
emptyTree = RevTree.EMPTY;
featuresLeafTree = createFeaturesTree(source, "featuresLeafTree", 100).build();
assertTrue(featuresLeafTree.features().isPresent());
treesLeafTree = createTreesTree(source, 100, 10, metadataId).build();
assertTrue(treesLeafTree.trees().isPresent());
RevTreeBuilder builder = createTreesTree(source, 10, 10, metadataId);
for (int i = 0; i < 100; i++) {
builder.put(featureNode("feature.", i));
}
mixedLeafTree = builder.build();
featuresBucketsTree = createFeaturesTree(source, "feature.", 25000).build();
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DiffCountConsumerTest method testChildrenChildren.
@Test
public void testChildrenChildren() {
RevTreeBuilder builder = new RevTreeBuilder(odb, childrenFeatureTree);
RevTree changed = builder.remove("3").build();
assertEquals(1, count(childrenFeatureTree, changed).featureCount());
assertEquals(1, count(changed, childrenFeatureTree).featureCount());
changed = builder.put(Node.create("new", FAKE_FEATURE_ID, ObjectId.NULL, TYPE.FEATURE, null)).build();
assertEquals(2, count(childrenFeatureTree, changed).featureCount());
assertEquals(2, count(changed, childrenFeatureTree).featureCount());
changed = builder.put(Node.create("1", FAKE_FEATURE_ID_CHANGED, ObjectId.NULL, TYPE.FEATURE, null)).build();
assertEquals(3, count(childrenFeatureTree, changed).featureCount());
assertEquals(3, count(changed, childrenFeatureTree).featureCount());
}
Aggregations