Search in sources :

Example 46 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class ReportCommitConflictsOpTest method testModifiedAndNonExistant.

@Test
public void testModifiedAndNonExistant() throws Exception {
    insertAndAdd(points2);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    insertAndAdd(points1Modified);
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class).setCommit(branchCommit).call();
    assertEquals(0, conflicts.getConflicts().size());
    assertEquals(1, conflicts.getUnconflicted().size());
}
Also used : CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 47 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class ReportMergeConflictsOpTest method testModifiedSameFeatureCompatible.

@Test
public void testModifiedSameFeatureCompatible() throws Exception {
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    insertAndAdd(points1Modified);
    RevCommit masterCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_1", new Integer(2000), "POINT(1 1)");
    insertAndAdd(points1ModifiedB);
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    MergeScenarioReport conflicts = geogig.command(ReportMergeScenarioOp.class).setMergeIntoCommit(masterCommit).setToMergeCommit(branchCommit).call();
    assertEquals(0, conflicts.getConflicts().size());
    assertEquals(0, conflicts.getUnconflicted().size());
    assertEquals(1, conflicts.getMerged().size());
    Feature pointsMerged = feature(pointsType, idP1, "StringProp1_2", new Integer(2000), "POINT(1 1)");
    assertEquals(pointsMerged, conflicts.getMerged().get(0).getFeature());
    Boolean hasConflictsOrAutomerge = geogig.command(CheckMergeScenarioOp.class).setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
    assertTrue(hasConflictsOrAutomerge.booleanValue());
}
Also used : ReportMergeScenarioOp(org.locationtech.geogig.api.plumbing.merge.ReportMergeScenarioOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 48 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class RebaseOpTest method testRebaseWithConflictAndContinue.

@Test
public void testRebaseWithConflictAndContinue() throws Exception {
    // Create the following revision graph
    // o
    // |
    // o - Points 1,2 added
    // |\
    // | o - branch1 - Points 1 modifiedB, 2 removed, 3 added
    // |
    // o - Points 1 modified, 2 removed
    // |
    // o - master - HEAD - Lines 1 added
    insertAndAdd(points1, points2);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("branch1").call();
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    insert(points1Modified);
    delete(points2);
    geogig.command(AddOp.class).call();
    RevCommit masterCommit2 = geogig.command(CommitOp.class).setMessage("adding points1 modified, deleting point2").call();
    insert(lines1);
    geogig.command(AddOp.class).call();
    RevCommit masterCommit = geogig.command(CommitOp.class).setMessage("adding lines.1").call();
    geogig.command(CheckoutOp.class).setSource("branch1").call();
    insert(points3);
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    insert(points1ModifiedB);
    delete(points2);
    geogig.command(AddOp.class).call();
    RevCommit branchCommit = geogig.command(CommitOp.class).setMessage("branch commit").call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
    try {
        geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(branch1.getObjectId())).call();
        fail();
    } catch (RebaseConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call();
    assertTrue(ref.isPresent());
    assertEquals(masterCommit.getId(), ref.get().getObjectId());
    List<Conflict> conflicts = geogig.command(ConflictsReadOp.class).call();
    assertEquals(1, conflicts.size());
    String path = NodeRef.appendChild(pointsName, idP1);
    assertEquals(conflicts.get(0).getPath(), path);
    assertEquals(conflicts.get(0).getOurs(), RevFeatureBuilder.build(points1Modified).getId());
    assertEquals(conflicts.get(0).getTheirs(), RevFeatureBuilder.build(points1ModifiedB).getId());
    // solve, and continue
    Feature points1Merged = feature(pointsType, idP1, "StringProp1_2", new Integer(2000), "POINT(1 1)");
    insert(points1Merged);
    geogig.command(AddOp.class).call();
    geogig.command(RebaseOp.class).setContinue(true).call();
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    RevCommit logCommit1 = log.next();
    assertEquals(masterCommit.getAuthor(), logCommit1.getAuthor());
    assertEquals(masterCommit.getCommitter().getName(), logCommit1.getCommitter().getName());
    assertEquals(masterCommit.getMessage(), logCommit1.getMessage());
    assertEquals(masterCommit.getAuthor().getTimeZoneOffset(), logCommit1.getAuthor().getTimeZoneOffset());
    assertEquals(masterCommit.getAuthor().getTimestamp(), logCommit1.getAuthor().getTimestamp());
    assertEquals(masterCommit.getCommitter().getTimeZoneOffset(), logCommit1.getCommitter().getTimeZoneOffset());
    assertNotSame(masterCommit.getCommitter().getTimestamp(), logCommit1.getCommitter().getTimestamp());
    assertNotSame(masterCommit.getTreeId(), logCommit1.getTreeId());
    RevCommit logCommit2 = log.next();
    assertEquals(masterCommit2.getAuthor(), logCommit2.getAuthor());
    assertEquals(masterCommit2.getCommitter().getName(), logCommit2.getCommitter().getName());
    assertEquals(masterCommit2.getMessage(), logCommit2.getMessage());
    RevCommit logCommit3 = log.next();
    assertEquals(branchCommit.getAuthor(), logCommit3.getAuthor());
    assertEquals(branchCommit.getCommitter().getName(), logCommit3.getCommitter().getName());
    assertEquals(branchCommit.getMessage(), logCommit3.getMessage());
    ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call();
    assertFalse(ref.isPresent());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) ConflictsReadOp(org.locationtech.geogig.api.plumbing.merge.ConflictsReadOp) RebaseConflictsException(org.locationtech.geogig.api.porcelain.RebaseConflictsException) LogOp(org.locationtech.geogig.api.porcelain.LogOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevFeature(org.locationtech.geogig.api.RevFeature) Feature(org.opengis.feature.Feature) Ref(org.locationtech.geogig.api.Ref) SymRef(org.locationtech.geogig.api.SymRef) NodeRef(org.locationtech.geogig.api.NodeRef) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) RefParse(org.locationtech.geogig.api.plumbing.RefParse) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 49 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class RebaseOpTest method testRebaseAbort.

@Test
public void testRebaseAbort() throws Exception {
    // Create the following revision graph
    // o
    // |
    // o - Points 1,2 added
    // |\
    // | o - branch1 - Points 1 modifiedB, 2 removed, 3 added
    // |
    // o - Points 1 modified, 2 removed
    // |
    // o - master - HEAD - Lines 1 added
    insertAndAdd(points1, points2);
    RevCommit firstCommit = geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("branch1").call();
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    insert(points1Modified);
    delete(points2);
    geogig.command(AddOp.class).call();
    RevCommit masterCommit2 = geogig.command(CommitOp.class).setMessage("adding points1 modified, deleting point2").call();
    insert(lines1);
    geogig.command(AddOp.class).call();
    RevCommit masterCommit = geogig.command(CommitOp.class).setMessage("adding lines.1").call();
    geogig.command(CheckoutOp.class).setSource("branch1").call();
    insert(points3);
    Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
    insert(points1ModifiedB);
    delete(points2);
    geogig.command(AddOp.class).call();
    geogig.command(CommitOp.class).setMessage("branch commit").call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
    try {
        geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(branch1.getObjectId())).call();
        fail();
    } catch (RebaseConflictsException e) {
        assertTrue(e.getMessage().contains("conflict"));
    }
    geogig.command(RebaseOp.class).setAbort(true).call();
    Optional<Ref> head = geogig.command(RefParse.class).setName(Ref.HEAD).call();
    assertTrue(head.isPresent());
    assertEquals(head.get().getObjectId(), masterCommit.getId());
    Iterator<RevCommit> log = geogig.command(LogOp.class).call();
    RevCommit logCommit1 = log.next();
    assertEquals(masterCommit.getMessage(), logCommit1.getMessage());
    RevCommit logCommit2 = log.next();
    assertEquals(masterCommit2.getMessage(), logCommit2.getMessage());
    RevCommit logCommit3 = log.next();
    assertEquals(firstCommit.getMessage(), logCommit3.getMessage());
    String path = NodeRef.appendChild(pointsName, idP1);
    Optional<RevFeature> points = geogig.command(RevObjectParse.class).setRefSpec(Ref.HEAD + ":" + path).call(RevFeature.class);
    assertTrue(points.isPresent());
    assertEquals(RevFeatureBuilder.build(points1Modified), points.get());
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) RebaseConflictsException(org.locationtech.geogig.api.porcelain.RebaseConflictsException) LogOp(org.locationtech.geogig.api.porcelain.LogOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevFeature(org.locationtech.geogig.api.RevFeature) Feature(org.opengis.feature.Feature) Ref(org.locationtech.geogig.api.Ref) SymRef(org.locationtech.geogig.api.SymRef) NodeRef(org.locationtech.geogig.api.NodeRef) RevFeature(org.locationtech.geogig.api.RevFeature) RefParse(org.locationtech.geogig.api.plumbing.RefParse) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 50 with Feature

use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.

the class ReportCommitConflictsOpTest method testModifiedAndRemoved.

@Test
public void testModifiedAndRemoved() throws Exception {
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    geogig.command(BranchCreateOp.class).setName("TestBranch").call();
    Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
    insertAndAdd(points1Modified);
    geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("TestBranch").call();
    deleteAndAdd(points1);
    RevCommit branchCommit = geogig.command(CommitOp.class).call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    MergeScenarioReport conflicts = geogig.command(ReportCommitConflictsOp.class).setCommit(branchCommit).call();
    assertEquals(1, conflicts.getConflicts().size());
    assertEquals(0, conflicts.getUnconflicted().size());
}
Also used : CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) MergeScenarioReport(org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport) Feature(org.opengis.feature.Feature) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

Feature (org.opengis.feature.Feature)128 Test (org.junit.Test)90 RevCommit (org.locationtech.geogig.api.RevCommit)52 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)43 SimpleFeature (org.opengis.feature.simple.SimpleFeature)38 ObjectId (org.locationtech.geogig.api.ObjectId)35 RevFeature (org.locationtech.geogig.api.RevFeature)32 NodeRef (org.locationtech.geogig.api.NodeRef)29 LinkedList (java.util.LinkedList)27 LogOp (org.locationtech.geogig.api.porcelain.LogOp)23 Ref (org.locationtech.geogig.api.Ref)21 RefParse (org.locationtech.geogig.api.plumbing.RefParse)19 SimpleFeatureStore (org.geotools.data.simple.SimpleFeatureStore)18 ArrayList (java.util.ArrayList)16 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)16 RevObject (org.locationtech.geogig.api.RevObject)16 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)14 Function (com.google.common.base.Function)13 Optional (com.google.common.base.Optional)12 HashMap (java.util.HashMap)12