Search in sources :

Example 56 with DiffEntry

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

Example 57 with DiffEntry

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());
}
Also used : DiffOp(org.locationtech.geogig.api.porcelain.DiffOp) Feature(org.opengis.feature.Feature) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 58 with DiffEntry

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

Example 59 with DiffEntry

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

Example 60 with DiffEntry

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());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) DiffOp(org.locationtech.geogig.api.porcelain.DiffOp) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) 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