use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class ReportMergeConflictsOpTest method testModifiedSameAttributeCompatible.
@Test
public void testModifiedSameAttributeCompatible() 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_2", 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(1, conflicts.getUnconflicted().size());
Boolean hasConflictsOrAutomerge = geogig.command(CheckMergeScenarioOp.class).setCommits(Lists.newArrayList(masterCommit, branchCommit)).call();
assertTrue(hasConflictsOrAutomerge.booleanValue());
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class RepositoryTestCase method boundsOf.
/**
* Computes the aggregated bounds of {@code features} in the {@code targetCrs}
*/
public ReferencedEnvelope boundsOf(CoordinateReferenceSystem targetCrs, Feature... features) throws Exception {
ReferencedEnvelope bounds = new ReferencedEnvelope(targetCrs);
for (int i = 0; i < features.length; i++) {
Feature f = features[i];
BoundingBox fbounds = f.getBounds();
if (!CRS.equalsIgnoreMetadata(targetCrs, fbounds)) {
fbounds = fbounds.toBounds(targetCrs);
}
bounds.include(fbounds);
}
return bounds;
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class ResetOpTest method testResetFixesConflict.
@Test
public void testResetFixesConflict() throws Exception {
Feature points1Modified = feature(pointsType, idP1, "StringProp1_2", new Integer(1000), "POINT(1 1)");
Feature points1ModifiedB = feature(pointsType, idP1, "StringProp1_3", new Integer(2000), "POINT(1 1)");
insertAndAdd(points1);
RevCommit resetCommit = geogig.command(CommitOp.class).call();
geogig.command(BranchCreateOp.class).setName("TestBranch").call();
insertAndAdd(points1Modified);
geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("TestBranch").call();
insertAndAdd(points1ModifiedB);
insertAndAdd(points2);
geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("master").call();
Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get();
try {
geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId())).call();
fail();
} catch (MergeConflictsException e) {
assertTrue(e.getMessage().contains("conflict"));
}
geogig.command(ResetOp.class).setMode(ResetMode.HARD).setCommit(Suppliers.ofInstance(resetCommit.getId())).call();
List<Conflict> conflicts = geogig.getRepository().stagingDatabase().getConflicts(null, null);
assertTrue(conflicts.isEmpty());
Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.MERGE_HEAD).call();
assertFalse(ref.isPresent());
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class ReportCommitConflictsOpTest 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);
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();
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());
}
use of org.opengis.feature.Feature in project GeoGig by boundlessgeo.
the class RevertOpTest method testRevertModifiedFeatureConflictAndAbort.
@Test
public void testRevertModifiedFeatureConflictAndAbort() throws Exception {
insertAndAdd(points1);
@SuppressWarnings("unused") RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
insertAndAdd(points1_modified);
RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1).call();
Feature points1_modifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000), "POINT(1 1)");
ObjectId oId = insertAndAdd(points1_modifiedB);
RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1 + " again").call();
try {
geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).call();
fail();
} catch (RevertConflictsException e) {
assertTrue(e.getMessage().contains(idP1));
}
Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call();
assertTrue(ref.isPresent());
assertEquals(c3.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(points1_modifiedB).getId());
assertEquals(conflicts.get(0).getTheirs(), RevFeatureBuilder.build(points1).getId());
geogig.command(RevertOp.class).setAbort(true).call();
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
RevTree headTree = repo.getTree(headTreeId.get());
Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
assertTrue(points1Node.isPresent());
assertEquals(oId, points1Node.get().getNode().getObjectId());
}
Aggregations