use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class ApplyPatchOpTest method testRemoveEmptyFeatureTypePatch.
@Test
public void testRemoveEmptyFeatureTypePatch() throws Exception {
WorkingTree workingTree = geogig.getRepository().workingTree();
workingTree.createTypeTree(pointsName, pointsType);
geogig.command(AddOp.class).setUpdateOnly(false).call();
Patch patch = new Patch();
RevFeatureType featureType = RevFeatureTypeImpl.build(pointsType);
patch.addFeatureType(featureType);
patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null));
geogig.command(ApplyPatchOp.class).setPatch(patch).call();
RevTree root = repo.workingTree().getTree();
assertNotNull(root);
Optional<Node> typeTree = findTreeChild(root, pointsName);
assertFalse(typeTree.isPresent());
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class ApplyPatchOpTest method testPartialApplication.
@Test
public void testPartialApplication() throws Exception {
insert(points1, points2);
Patch patch = new Patch();
String pathRemove = NodeRef.appendChild(pointsName, points2.getIdentifier().getID());
patch.addRemovedFeature(pathRemove, points2, RevFeatureTypeImpl.build(pointsType));
String pathModify = NodeRef.appendChild(pointsName, points1B.getIdentifier().getID());
Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap();
Optional<?> oldValue = Optional.fromNullable(points1B.getProperty("extra").getValue());
GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, null);
map.put(modifiedPointsType.getDescriptor("extra"), diff);
FeatureDiff featureDiff = new FeatureDiff(pathModify, map, RevFeatureTypeImpl.build(modifiedPointsType), RevFeatureTypeImpl.build(pointsType));
patch.addModifiedFeature(featureDiff);
Patch rejected = geogig.command(ApplyPatchOp.class).setPatch(patch).setApplyPartial(true).call();
assertFalse(rejected.isEmpty());
RevTree root = repo.workingTree().getTree();
assertNotNull(root);
Optional<Node> featureBlobId = findTreeChild(root, pathRemove);
assertFalse(featureBlobId.isPresent());
// now we take the rejected patch and apply it, and the new rejected should be identical to
// it
Patch newRejected = geogig.command(ApplyPatchOp.class).setPatch(rejected).setApplyPartial(true).call();
assertEquals(rejected, newRejected);
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class ApplyPatchOpTest method testRemoveFeaturePatch.
@Test
public void testRemoveFeaturePatch() throws Exception {
insert(points1);
Patch patch = new Patch();
String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
patch.addRemovedFeature(path, points1, RevFeatureTypeImpl.build(pointsType));
geogig.command(ApplyPatchOp.class).setPatch(patch).call();
RevTree root = repo.workingTree().getTree();
assertNotNull(root);
Optional<Node> featureBlobId = findTreeChild(root, path);
assertFalse(featureBlobId.isPresent());
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class RevTreeSerializationTest method testRoundTripSpatialInternalTree.
@Test
public void testRoundTripSpatialInternalTree() {
RevTree roundTripped = read(tree5_spatial_internal.getId(), write(tree5_spatial_internal));
assertTreesAreEqual(tree5_spatial_internal, roundTripped);
}
use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.
the class RevTreeSerializationTest method write.
private byte[] write(RevTree tree) {
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectWriter<RevTree> treeWriter = factory.<RevTree>createObjectWriter(RevObject.TYPE.TREE);
treeWriter.write(tree, bout);
return bout.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations