@Test
 public void testReversedPatch() throws Exception {
   insert(points1, points2);
   Patch patch = new Patch();
   String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
   Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap();
   Optional<?> oldValue = Optional.fromNullable(points1.getProperty("sp").getValue());
   GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, Optional.of("new"));
   map.put(pointsType.getDescriptor("sp"), diff);
   FeatureDiff feaureDiff =
       new FeatureDiff(
           path, map, RevFeatureType.build(pointsType), RevFeatureType.build(pointsType));
   patch.addModifiedFeature(feaureDiff);
   String removedPath = NodeRef.appendChild(pointsName, points2.getIdentifier().getID());
   patch.addRemovedFeature(removedPath, points2, RevFeatureType.build(pointsType));
   String addedPath = NodeRef.appendChild(pointsName, points3.getIdentifier().getID());
   patch.addAddedFeature(addedPath, points3, RevFeatureType.build(pointsType));
   geogit.command(ApplyPatchOp.class).setPatch(patch).call();
   geogit.command(ApplyPatchOp.class).setPatch(patch.reversed()).call();
   RevTree root = repo.getWorkingTree().getTree();
   Optional<Node> featureBlobId = findTreeChild(root, removedPath);
   assertTrue(featureBlobId.isPresent());
   featureBlobId = findTreeChild(root, addedPath);
   assertFalse(featureBlobId.isPresent());
   Optional<RevFeature> feature =
       geogit.command(RevObjectParse.class).setRefSpec("WORK_HEAD:" + path).call(RevFeature.class);
   assertTrue(feature.isPresent());
   assertEquals(oldValue, feature.get().getValues().get(0));
 }
 @Test
 public void testAddedFeatureExists() throws Exception {
   insert(points1);
   Patch patch = new Patch();
   String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
   patch.addAddedFeature(path, points1, RevFeatureType.build(pointsType));
   try {
     geogit.command(ApplyPatchOp.class).setPatch(patch).call();
     fail();
   } catch (CannotApplyPatchException e) {
     assertTrue(true);
   }
 }
 @Test
 public void testAddFeaturePatch() throws Exception {
   Patch patch = new Patch();
   String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
   patch.addAddedFeature(path, points1, RevFeatureType.build(pointsType));
   geogit.command(ApplyPatchOp.class).setPatch(patch).call();
   RevTree root = repo.getWorkingTree().getTree();
   assertNotNull(root);
   Optional<Node> typeTreeId = findTreeChild(root, pointsName);
   RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
   assertNotNull(typeTree);
   Optional<Node> featureBlobId = findTreeChild(root, path);
   assertTrue(featureBlobId.isPresent());
 }
 @Test
 public void testAddFeatureWithNonDefaultFeatureType() throws Exception {
   insert(points2, points3);
   Patch patch = new Patch();
   String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
   patch.addAddedFeature(path, points1B, RevFeatureType.build(modifiedPointsType));
   geogit.command(ApplyPatchOp.class).setPatch(patch).call();
   RevTree root = repo.getWorkingTree().getTree();
   assertNotNull(root);
   Optional<Node> typeTreeId = findTreeChild(root, pointsName);
   assertEquals(typeTreeId.get().getMetadataId().get(), RevFeatureType.build(pointsType).getId());
   RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
   assertNotNull(typeTree);
   Optional<Node> featureBlobId = findTreeChild(root, path);
   assertEquals(
       RevFeatureType.build(modifiedPointsType).getId(),
       featureBlobId.get().getMetadataId().orNull());
   assertTrue(featureBlobId.isPresent());
   path = NodeRef.appendChild(pointsName, points3.getIdentifier().getID());
   featureBlobId = findTreeChild(root, path);
   assertEquals(null, featureBlobId.get().getMetadataId().orNull());
 }