public void testMergeWithPolygonAutoMerge() throws Exception {
String polyId = "polyId";
String polygonTypeSpec = "poly:Polygon:srid=4326";
SimpleFeatureType polygonType = DataUtilities.createType("http://geogig.polygon",
"polygons", polygonTypeSpec);
Feature polygonOriginal = feature(polygonType, polyId,
"POLYGON((0 0,1 0,2 0,3 0,4 0,5 0,5 1,4 1,3 1,2 1,1 1,1 0,0 0))");
insertAndAdd(polygonOriginal);
geogig.command(CommitOp.class).call();
geogig.command(BranchCreateOp.class).setName("TestBranch").call();
Feature polygonMaster = feature(polygonType, polyId,
"POLYGON((0 0,1 0,2 0.2,3 0.2,4 0,5 0,5 1,4 1,3 1,2 1,1 1,1 0,0 0))");
insertAndAdd(polygonMaster);
geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("TestBranch").call();
Feature polygonBranch = feature(polygonType, polyId,
"POLYGON((0 0,1 0,2 0,3 0,4 0,5 0,5 1,4 1,3 0.8,2 0.8,1 1,1 0,0 0))");
insertAndAdd(polygonBranch);
geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("master").call();
Ref branch = geogig.command(RefParse.class).setName("TestBranch").call().get();
geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch.getObjectId())).call();
Optional<RevFeature> feature = repo.command(RevObjectParse.class)
.setRefSpec("WORK_HEAD:polygons/polyId").call(RevFeature.class);
assertTrue(feature.isPresent());
RevFeature merged = feature.get();
Feature expected = feature(polygonType, polyId,
"POLYGON((0 0,1 0,2 0.2,3 0.2,4 0,5 0,5 1,4 1,3 0.8,2 0.8,1 1,1 0,0 0))");
assertEquals(expected.getProperty("poly").getValue(), merged.getValues().get(0).get());
}