use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffOpTest method testDiffPreconditions.
@Test
public void testDiffPreconditions() throws Exception {
Iterator<DiffEntry> difflist = geogig.command(DiffOp.class).call();
assertNotNull(difflist);
assertFalse(difflist.hasNext());
final ObjectId oid1 = insertAndAdd(points1);
final RevCommit commit1_1 = geogig.command(CommitOp.class).call();
try {
diffOp.setOldVersion(oid1.toString()).setNewVersion(Ref.HEAD).call();
fail("Expected IAE as oldVersion is not a commit");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage(), e.getMessage().contains(oid1.toString()));
assertTrue(e.getMessage(), e.getMessage().contains("doesn't resolve to a tree-ish object"));
}
try {
diffOp.setOldVersion(commit1_1.getId().toString()).setNewVersion(oid1.toString()).call();
fail("Expected IAE as newVersion is not a commit");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage(), e.getMessage().contains(oid1.toString()));
assertTrue(e.getMessage(), e.getMessage().contains("doesn't resolve to a tree-ish object"));
}
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class CreatePatchOpTest method testCreatePatch.
@Test
public void testCreatePatch() throws Exception {
insertAndAdd(points1, points2);
geogig.command(CommitOp.class).setAll(true).call();
final String featureId = points1.getIdentifier().getID();
final Feature modifiedFeature = feature((SimpleFeatureType) points1.getType(), featureId, "changedProp", new Integer(1500), "POINT (2 2)");
insert(modifiedFeature);
insert(points3);
delete(points2);
Iterator<DiffEntry> diffs = geogig.command(DiffOp.class).call();
Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
assertEquals(3, patch.count());
assertEquals(1, patch.getAddedFeatures().size());
assertEquals(1, patch.getRemovedFeatures().size());
assertEquals(1, patch.getModifiedFeatures().size());
assertEquals(RevFeatureTypeImpl.build(pointsType), patch.getFeatureTypes().get(0));
assertEquals(NodeRef.appendChild(pointsName, idP2), patch.getRemovedFeatures().get(0).getPath());
assertEquals(NodeRef.appendChild(pointsName, idP3), patch.getAddedFeatures().get(0).getPath());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class CreatePatchOpTest method testCreatePatchAddNewFeatureToEmptyRepo.
@Test
public void testCreatePatchAddNewFeatureToEmptyRepo() throws Exception {
insert(points1);
DiffOp op = geogig.command(DiffOp.class);
Iterator<DiffEntry> diffs = op.call();
Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
assertEquals(1, patch.getAddedFeatures().size());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class CreatePatchOpTest method testCreatePatchAddNewEmptyFeatureTypeToEmptyRepo.
@Test
public void testCreatePatchAddNewEmptyFeatureTypeToEmptyRepo() throws Exception {
WorkingTree workingTree = geogig.getRepository().workingTree();
workingTree.createTypeTree(linesName, linesType);
DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);
Iterator<DiffEntry> diffs = op.call();
Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
assertEquals(1, patch.getAlteredTrees().size());
assertEquals(ObjectId.NULL, patch.getAlteredTrees().get(0).getOldFeatureType());
assertEquals(RevFeatureTypeImpl.build(linesType).getId(), patch.getAlteredTrees().get(0).getNewFeatureType());
assertEquals(1, patch.getFeatureTypes().size());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class CreatePatchOpTest method testCreatePatchRemoveEmptyFeatureType.
@Test
public void testCreatePatchRemoveEmptyFeatureType() throws Exception {
WorkingTree workingTree = geogig.getRepository().workingTree();
workingTree.createTypeTree(linesName, linesType);
geogig.command(AddOp.class).setUpdateOnly(false).call();
workingTree.delete(linesName);
DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);
Iterator<DiffEntry> diffs = op.call();
Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
assertEquals(1, patch.getAlteredTrees().size());
assertEquals(RevFeatureTypeImpl.build(linesType).getId(), patch.getAlteredTrees().get(0).getOldFeatureType());
assertEquals(ObjectId.NULL, patch.getAlteredTrees().get(0).getNewFeatureType());
assertEquals(1, patch.getFeatureTypes().size());
}
Aggregations