@Test public void testModifiedFeatureDoesNotExists() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1.getProperty("sp").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, "new"); map.put(pointsType.getDescriptor("sp"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testRemovedFeatureDoesNotExists() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addRemovedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testModifyFeatureAttributeOutdatedPatch() throws Exception { insert(points1_modified); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1.getProperty("sp").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, "new"); map.put(pointsType.getDescriptor("sp"), diff); FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(feaureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testAddFeatureAttributeOutdatedPatch() throws Exception { insert(points1B); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object newValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(modifiedPointsType), RevFeatureTypeBuilder.build(modifiedPointsType)); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testRemoveFeatureAttributeOutdatedPatch() throws Exception { insert(points1B_modified); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1B.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, null); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(modifiedPointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testModifiedFeatureDoesNotExists() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1.getProperty("sp").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, "new"); map.put(pointsType.getDescriptor("sp"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testAddedFeatureExists() throws Exception { insert(points1); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testModifyFeatureAttributeOutdatedPatch() throws Exception { insert(points1_modified); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1.getProperty("sp").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, "new"); map.put(pointsType.getDescriptor("sp"), diff); FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(feaureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testRemoveFeatureAttributeOutdatedPatch() throws Exception { insert(points1B_modified); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1B.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object oldValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, null); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(modifiedPointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testAddFeatureAttributeOutdatedPatch() throws Exception { insert(points1B); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap(); Object newValue = points1B.getProperty("extra").getValue(); GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue); map.put(modifiedPointsType.getDescriptor("extra"), diff); FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(modifiedPointsType).build(), RevFeatureType.builder().type(modifiedPointsType).build()); patch.addModifiedFeature(featureDiff); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testRemovedFeatureDoesNotExists() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addRemovedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }
@Test public void testAddedFeatureExists() throws Exception { insert(points1); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeature.builder().build(points1), RevFeatureType.builder().type(pointsType).build()); try { geogig.command(ApplyPatchOp.class).setPatch(patch).call(); fail(); } catch (CannotApplyPatchException e) { assertTrue(true); } }