use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class CommitOpTest method testPathFilteringWithUnstaged.
@Test
public void testPathFilteringWithUnstaged() throws Exception {
insertAndAdd(points1);
insertAndAdd(points2);
RevCommit commit = geogig.command(CommitOp.class).call();
insertAndAdd(lines1);
insertAndAdd(lines3);
insert(lines2);
insert(points3);
List<String> filters = Arrays.asList(pointsName, linesName);
commit = geogig.command(CommitOp.class).setPathFilters(filters).call();
assertNotNull(commit);
assertNotNull(commit.getParentIds());
assertEquals(1, commit.getParentIds().size());
assertNotNull(commit.getId());
ObjectId treeId = commit.getTreeId();
assertNotNull(treeId);
RevTree root = repo.getTree(treeId);
assertNotNull(root);
Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
assertTrue(typeTreeId.isPresent());
RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
assertNotNull(typeTree);
String featureId = points1.getIdentifier().getID();
Optional<Node> featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
assertTrue(featureBlobId.isPresent());
featureId = points2.getIdentifier().getID();
featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
assertTrue(featureBlobId.isPresent());
featureId = points3.getIdentifier().getID();
featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
assertFalse(featureBlobId.isPresent());
typeTreeId = repo.getTreeChild(root, linesName);
assertTrue(typeTreeId.isPresent());
typeTree = repo.getTree(typeTreeId.get().getObjectId());
assertNotNull(typeTree);
featureId = lines1.getIdentifier().getID();
featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(linesName, featureId));
assertTrue(featureBlobId.isPresent());
featureId = lines2.getIdentifier().getID();
featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(linesName, featureId));
assertFalse(featureBlobId.isPresent());
featureId = lines3.getIdentifier().getID();
featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(linesName, featureId));
assertTrue(featureBlobId.isPresent());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class DiffOpTest method testReportRename.
@Test
public void testReportRename() throws Exception {
insertAndAdd(lines1);
final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call();
Feature lines1B = feature(linesType, idL2, "StringProp2_1", new Integer(1000), "LINESTRING (1 1, 2 2)");
delete(lines1);
// insert(lines2);
WorkingTree workTree = repo.workingTree();
Name name = lines1.getType().getName();
String parentPath = name.getLocalPart();
@SuppressWarnings("unused") Node ref = workTree.insert(parentPath, lines1B);
geogig.command(AddOp.class).call();
RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call();
List<DiffEntry> diffs;
diffOp.setOldVersion(commit1.getId());
diffOp.setNewVersion(commit2.getId());
diffs = toList(diffOp.call());
// this is reported as an addition and a removal, with both
assertEquals(2, diffs.size());
// nodes pointing to same ObjectId
assertEquals(diffs.get(0).newObjectId(), diffs.get(1).oldObjectId());
assertEquals(diffs.get(1).newObjectId(), diffs.get(0).oldObjectId());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class RemoteRepositoryTestCase method insert.
/**
* Inserts the feature to the index but does not stages it to be committed
*/
protected ObjectId insert(GeoGIG geogig, Feature f) throws Exception {
final WorkingTree workTree = geogig.getRepository().workingTree();
Name name = f.getType().getName();
String parentPath = name.getLocalPart();
Node ref = workTree.insert(parentPath, f);
ObjectId objectId = ref.getObjectId();
return objectId;
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class ApplyPatchOpTest method testAddFeaturePatch.
@Test
public void testAddFeaturePatch() throws Exception {
Patch patch = new Patch();
String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
patch.addAddedFeature(path, points1, RevFeatureTypeImpl.build(pointsType));
geogig.command(ApplyPatchOp.class).setPatch(patch).call();
RevTree root = repo.workingTree().getTree();
assertNotNull(root);
Optional<Node> typeTreeId = findTreeChild(root, pointsName);
RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
assertNotNull(typeTree);
Optional<Node> featureBlobId = findTreeChild(root, path);
assertTrue(featureBlobId.isPresent());
}
use of org.locationtech.geogig.api.Node in project GeoGig by boundlessgeo.
the class ApplyPatchOpTest method testModifyFeatureAttributePatch.
@Test
public void testModifyFeatureAttributePatch() throws Exception {
insert(points1);
Patch patch = new Patch();
String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap();
Optional<?> oldValue = Optional.fromNullable(points1.getProperty("sp").getValue());
GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, Optional.of("new"));
map.put(pointsType.getDescriptor("sp"), diff);
FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureTypeImpl.build(pointsType), RevFeatureTypeImpl.build(pointsType));
patch.addModifiedFeature(feaureDiff);
geogig.command(ApplyPatchOp.class).setPatch(patch).call();
RevTree root = repo.workingTree().getTree();
Optional<Node> featureBlobId = findTreeChild(root, path);
assertTrue(featureBlobId.isPresent());
Iterator<DiffEntry> unstaged = repo.workingTree().getUnstaged(pointsName);
ArrayList<DiffEntry> diffs = Lists.newArrayList(unstaged);
assertEquals(2, diffs.size());
Optional<RevFeature> feature = geogig.command(RevObjectParse.class).setRefSpec("WORK_HEAD:" + path).call(RevFeature.class);
assertTrue(feature.isPresent());
ImmutableList<Optional<Object>> values = feature.get().getValues();
assertEquals("new", values.get(0).get());
}
Aggregations