use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testInsertCollectionNullCollectionSize.
@Test
public void testInsertCollectionNullCollectionSize() throws Exception {
List<Feature> featureList = new LinkedList<Feature>();
featureList.add(points1);
featureList.add(points2);
featureList.add(points3);
List<Node> targetList = new LinkedList<Node>();
workTree.insert(pointsName, featureList.iterator(), LISTENER, targetList, null);
assertEquals(3, targetList.size());
Node ref1 = targetList.get(0);
Node ref2 = targetList.get(1);
Node ref3 = targetList.get(2);
assertEquals(ref1.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId());
assertEquals(ref2.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP2)).get().getObjectId());
assertEquals(ref3.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP3)).get().getObjectId());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testInsertSingle.
@Test
public void testInsertSingle() throws Exception {
Name name = points1.getType().getName();
String parentPath = name.getLocalPart();
Node ref = workTree.insert(parentPath, points1);
ObjectId objectId = ref.getObjectId();
assertEquals(objectId, workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testUpdateTypeTree.
@Test
public void testUpdateTypeTree() throws Exception {
insert(points2, points3);
insert(points1B);
RevTree root = repo.workingTree().getTree();
assertNotNull(root);
Optional<Node> typeTreeId = findTreeChild(root, pointsName);
assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureTypeImpl.build(pointsType).getId());
RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
assertNotNull(typeTree);
String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
Optional<Node> featureBlobId = findTreeChild(root, path);
assertTrue(featureBlobId.isPresent());
assertEquals(RevFeatureTypeImpl.build(modifiedPointsType).getId(), featureBlobId.get().getMetadataId().orNull());
path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID());
featureBlobId = findTreeChild(root, path);
assertEquals(null, featureBlobId.get().getMetadataId().orNull());
workTree.updateTypeTree(pointsName, modifiedPointsType);
root = repo.workingTree().getTree();
typeTreeId = findTreeChild(root, pointsName);
assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureTypeImpl.build(modifiedPointsType).getId());
typeTree = repo.getTree(typeTreeId.get().getObjectId());
assertNotNull(typeTree);
path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
featureBlobId = findTreeChild(root, path);
assertTrue(featureBlobId.isPresent());
assertEquals(null, featureBlobId.get().getMetadataId().orNull());
path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID());
featureBlobId = findTreeChild(root, path);
assertEquals(RevFeatureTypeImpl.build(pointsType).getId(), featureBlobId.get().getMetadataId().orNull());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class GlobalState method insert.
public static List<ObjectId> insert(Feature... features) throws Exception {
geogigCLI.close();
GeoGIG geogig = geogigCLI.newGeoGIG(Hints.readWrite());
Preconditions.checkNotNull(geogig);
List<ObjectId> ids = Lists.newArrayListWithCapacity(features.length);
try {
Repository repository = geogig.getRepository();
final WorkingTree workTree = repository.workingTree();
for (Feature f : features) {
Name name = f.getType().getName();
String parentPath = name.getLocalPart();
Node ref = workTree.insert(parentPath, f);
ObjectId objectId = ref.getObjectId();
ids.add(objectId);
}
} finally {
geogig.close();
}
return ids;
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class PostOrderDiffWalkTest method testLeafLeafWithSubStrees.
@Test
public void testLeafLeafWithSubStrees() {
// two leaf trees
ObjectId metadataId = ObjectId.forString("fake");
RevTree left = createTreesTree(leftSource, 2, 2, metadataId).build();
RevTree right = createTreesTree(rightSource, 3, 2, metadataId).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(4, leftCalls.size());
assertEquals(4, rightCalls.size());
assertNull(leftCalls.get(0));
assertNull(leftCalls.get(1));
assertNull(leftCalls.get(2));
assertEquals(lroot, leftCalls.get(3));
assertEquals(rroot, rightCalls.get(3));
assertNotNull(rightCalls.get(2));
assertEquals(RevObject.TYPE.TREE, ((Node) rightCalls.get(2)).getType());
assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(1)).getType());
assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(0)).getType());
}
Aggregations