use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffOpTest method testFilterFeatureIdNoChanges.
@Test
public void testFilterFeatureIdNoChanges() throws Exception {
// two commits on different trees
insertAndAdd(points1);
final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call();
insertAndAdd(lines1);
final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call();
// filter on feature1_1, it didn't change between commit2 and commit1
diffOp.setOldVersion(commit1.getId()).setNewVersion(commit2.getId());
diffOp.setFilter(NodeRef.appendChild(pointsName, points1.getIdentifier().getID()));
Iterator<DiffEntry> diffs = diffOp.call();
assertFalse(diffs.hasNext());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffOpTest method testFilterMatchesSingleBlobChange.
@Test
public void testFilterMatchesSingleBlobChange() throws Exception {
final ObjectId initialOid = insertAndAdd(points1);
final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call();
insertAndAdd(lines1);
final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call();
((SimpleFeature) points1).setAttribute("sp", "modified");
final ObjectId modifiedOid = insertAndAdd(points1);
final RevCommit commit3 = geogig.command(CommitOp.class).setAll(true).call();
diffOp.setOldVersion(commit1.getId()).setNewVersion(commit3.getId());
diffOp.setFilter(NodeRef.appendChild(pointsName, points1.getIdentifier().getID()));
List<DiffEntry> diffs;
DiffEntry diff;
diffs = toList(diffOp.call());
assertEquals(1, diffs.size());
diff = diffs.get(0);
assertEquals(ChangeType.MODIFIED, diff.changeType());
assertEquals(initialOid, diff.oldObjectId());
assertEquals(modifiedOid, diff.newObjectId());
assertTrue(deleteAndAdd(points1));
final RevCommit commit4 = geogig.command(CommitOp.class).setAll(true).call();
diffOp.setOldVersion(commit2.getId()).setNewVersion(commit4.getId());
diffOp.setFilter(NodeRef.appendChild(pointsName, points1.getIdentifier().getID()));
diffs = toList(diffOp.call());
assertEquals(1, diffs.size());
diff = diffs.get(0);
assertEquals(ChangeType.REMOVED, diff.changeType());
assertEquals(initialOid, diff.oldObjectId());
assertEquals(ObjectId.NULL, diff.newObjectId());
// invert the order of old and new commit
diffOp.setOldVersion(commit4.getId()).setNewVersion(commit1.getId());
diffOp.setFilter(NodeRef.appendChild(pointsName, points1.getIdentifier().getID()));
diffs = toList(diffOp.call());
assertEquals(1, diffs.size());
diff = diffs.get(0);
assertEquals(ChangeType.ADDED, diff.changeType());
assertEquals(ObjectId.NULL, diff.oldObjectId());
assertEquals(initialOid, diff.newObjectId());
// different commit range
diffOp.setOldVersion(commit4.getId()).setNewVersion(commit3.getId());
diffOp.setFilter(NodeRef.appendChild(pointsName, points1.getIdentifier().getID()));
diffs = toList(diffOp.call());
assertEquals(1, diffs.size());
diff = diffs.get(0);
assertEquals(ChangeType.ADDED, diff.changeType());
assertEquals(ObjectId.NULL, diff.oldObjectId());
assertEquals(modifiedOid, diff.newObjectId());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffOpTest method testFilterTypeNameNoChanges.
@Test
public void testFilterTypeNameNoChanges() throws Exception {
// two commits on different trees
insertAndAdd(points1);
final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call();
insertAndAdd(lines1);
final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call();
diffOp.setOldVersion(commit1.getId()).setNewVersion(commit2.getId());
diffOp.setFilter(pointsName);
Iterator<DiffEntry> diffs = diffOp.call();
assertFalse(diffs.hasNext());
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffOpTest method testMultipleDeletes.
// @Test
// public void testFilterAddressesNamespaceTree() throws Exception {
//
// // two commits on different trees
// final ObjectId oid11 = insertAndAdd(points1);
// final ObjectId oid12 = insertAndAdd(points2);
// final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call();
//
// final ObjectId oid21 = insertAndAdd(lines1);
// final ObjectId oid22 = insertAndAdd(lines2);
// final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call();
//
// List<DiffEntry> diffs;
//
// // filter on namespace1, no changes between commit1 and commit2
// diffOp.setOldVersion(commit1.getId());
// diffOp.setFilter(pointsNs);
//
// diffs = toList(diffOp.call());
// assertEquals(0, diffs.size());
//
// // filter on namespace2, all additions between commit1 and commit2
// diffOp.setOldVersion(commit1.getId());
// diffOp.setFilter(linesNs);
//
// diffs = toList(diffOp.call());
// assertEquals(2, diffs.size());
// assertEquals(ChangeType.ADD, diffs.get(0).getType());
// assertEquals(ChangeType.ADD, diffs.get(1).getType());
//
// assertEquals(ObjectId.NULL, diffs.get(0).getOldObjectId());
// assertEquals(ObjectId.NULL, diffs.get(1).getOldObjectId());
//
// // don't care about order
// Set<ObjectId> expected = new HashSet<ObjectId>();
// expected.add(oid21);
// expected.add(oid22);
// Set<ObjectId> actual = new HashSet<ObjectId>();
// actual.add(diffs.get(0).getNewObjectId());
// actual.add(diffs.get(1).getNewObjectId());
// assertEquals(expected, actual);
// }
@SuppressWarnings("unused")
@Test
public void testMultipleDeletes() throws Exception {
// two commits on different trees
final ObjectId oid11 = insertAndAdd(points1);
final ObjectId oid12 = insertAndAdd(points2);
final ObjectId oid13 = insertAndAdd(points3);
final RevCommit commit1 = geogig.command(CommitOp.class).setAll(true).call();
final ObjectId oid21 = insertAndAdd(lines1);
final RevCommit commit2 = geogig.command(CommitOp.class).setAll(true).call();
deleteAndAdd(points1);
deleteAndAdd(points3);
final RevCommit commit3 = geogig.command(CommitOp.class).setAll(true).call();
List<DiffEntry> diffs;
// filter on namespace1, no changes between commit1 and commit2
diffOp.setOldVersion(commit1.getId()).setNewVersion(commit3.getId());
diffOp.setFilter(pointsName);
diffs = toList(diffOp.call());
assertEquals(2, diffs.size());
assertEquals(ChangeType.REMOVED, diffs.get(0).changeType());
assertEquals(ChangeType.REMOVED, diffs.get(1).changeType());
Set<ObjectId> ids = Sets.newHashSet(diffs.get(0).oldObjectId(), diffs.get(1).oldObjectId());
assertEquals(Sets.newHashSet(oid11, oid13), ids);
}
use of org.locationtech.geogig.api.plumbing.diff.DiffEntry in project GeoGig by boundlessgeo.
the class DiffOpTest method testSingleAddition.
@Test
public void testSingleAddition() throws Exception {
final ObjectId newOid = insertAndAdd(points1);
geogig.command(CommitOp.class).setAll(true).call();
List<DiffEntry> difflist = toList(diffOp.setOldVersion(ObjectId.NULL).setNewVersion(Ref.HEAD).call());
assertNotNull(difflist);
assertEquals(1, difflist.size());
DiffEntry de = difflist.get(0);
assertNull(de.getOldObject());
assertNotNull(de.getNewObject());
String expectedPath = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
assertEquals(expectedPath, de.newPath());
assertEquals(DiffEntry.ChangeType.ADDED, de.changeType());
assertEquals(ObjectId.NULL, de.oldObjectId());
assertEquals(newOid, de.newObjectId());
assertFalse(de.getNewObject().getMetadataId().isNull());
}
Aggregations