Search in sources :

Example 61 with DiffEntry

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());
}
Also used : RevCommit(org.locationtech.geogig.api.RevCommit) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 62 with DiffEntry

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());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) SimpleFeature(org.opengis.feature.simple.SimpleFeature) RevCommit(org.locationtech.geogig.api.RevCommit) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 63 with DiffEntry

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());
}
Also used : RevCommit(org.locationtech.geogig.api.RevCommit) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 64 with DiffEntry

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);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) RevCommit(org.locationtech.geogig.api.RevCommit) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 65 with DiffEntry

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());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Aggregations

DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)83 ObjectId (org.locationtech.geogig.api.ObjectId)38 Test (org.junit.Test)31 RevCommit (org.locationtech.geogig.api.RevCommit)31 NodeRef (org.locationtech.geogig.api.NodeRef)24 DiffOp (org.locationtech.geogig.api.porcelain.DiffOp)17 RevFeature (org.locationtech.geogig.api.RevFeature)15 RevTree (org.locationtech.geogig.api.RevTree)15 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)14 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)14 RevObject (org.locationtech.geogig.api.RevObject)11 Patch (org.locationtech.geogig.api.plumbing.diff.Patch)11 Feature (org.opengis.feature.Feature)10 Optional (com.google.common.base.Optional)9 GeoGIG (org.locationtech.geogig.api.GeoGIG)8 Repository (org.locationtech.geogig.repository.Repository)8 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)8 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)8 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 IOException (java.io.IOException)5