@Override public AttributeDiff reversed() { return new GenericAttributeDiffImpl(newValue, oldValue); }
@Override public AttributeDiff reversed() { return new GenericAttributeDiffImpl(newValue, oldValue); }
@Given("^I have a patch file$") public void I_have_a_patch_file() throws Throwable { 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); File file = new File(localRepo.platform.pwd(), "test.patch"); BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); PatchSerializer.write(writer, patch); writer.flush(); writer.close(); }
@Given("^I have a patch file$") public void I_have_a_patch_file() throws Throwable { 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); File file = new File(localRepo.platform.pwd(), "test.patch"); BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); PatchSerializer.write(writer, patch); writer.flush(); writer.close(); }
@Test public void testAttributeDiffRemoved() { Integer oldValue = 1; Integer newValue = null; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.REMOVED, diff.getType()); assertEquals(oldValue, diff.getOldValue()); assertNull(diff.getNewValue()); }
@Test public void testAttributeDiffRemoved() { Integer oldValue = 1; Integer newValue = null; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.REMOVED, diff.getType()); assertEquals(oldValue, diff.getOldValue()); assertNull(diff.getNewValue()); }
@Test public void testAttributeDiffModified() { Integer oldValue = 1; Integer newValue = 2; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.MODIFIED, diff.getType()); assertEquals(oldValue, diff.getOldValue()); assertEquals(newValue, diff.getNewValue()); }
@Test public void testAttributeDiffModified() { Integer oldValue = 1; Integer newValue = 2; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.MODIFIED, diff.getType()); assertEquals(oldValue, diff.getOldValue()); assertEquals(newValue, diff.getNewValue()); }
@Test public void testAttributeDiffAdded() { Integer oldValue = null; Integer newValue = 1; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.ADDED, diff.getType()); assertNull(diff.getOldValue()); assertEquals(newValue, diff.getNewValue()); oldValue = null; diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.ADDED, diff.getType()); assertNull(diff.getOldValue()); assertEquals(newValue, diff.getNewValue()); }
@Test public void testAttributeDiffAdded() { Integer oldValue = null; Integer newValue = 1; AttributeDiff diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.ADDED, diff.getType()); assertNull(diff.getOldValue()); assertEquals(newValue, diff.getNewValue()); oldValue = null; diff = new GenericAttributeDiffImpl(oldValue, newValue); assertEquals(AttributeDiff.TYPE.ADDED, diff.getType()); assertNull(diff.getOldValue()); assertEquals(newValue, diff.getNewValue()); }
@Given("^I have a patch file$") public void I_have_a_patch_file() throws Throwable { 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); File file = new File(localRepo.platform.pwd(), "test.patch"); BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); PatchSerializer.write(writer, patch); writer.flush(); writer.close(); }
@Test public void testAddFeatureAttributePatch() throws Exception { 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(pointsType), RevFeatureTypeBuilder.build(modifiedPointsType)); patch.addModifiedFeature(featureDiff); patch.addFeatureType(RevFeatureTypeBuilder.build(modifiedPointsType)); testPatch(patch); }
@Test public void testRemoveFeatureAttributePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.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); patch.addFeatureType(RevFeatureTypeBuilder.build(pointsType)); testPatch(patch); }
@Test public void testModifyFeatureAttributePatch() 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"); Geometry oldGeometry = (Geometry) points1.getProperty("pp").getValue(); Geometry newGeometry = new WKTReader2().read("POINT (2 2)"); GeometryAttributeDiff geomDiff = new GeometryAttributeDiff(oldGeometry, newGeometry); map.put(pointsType.getDescriptor("sp"), diff); map.put(pointsType.getDescriptor("pp"), geomDiff); FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureTypeBuilder.build(pointsType), RevFeatureTypeBuilder.build(pointsType)); patch.addModifiedFeature(feaureDiff); testPatch(patch); }
@Test public void testAddFeatureAttributePatch() throws Exception { insert(points1); 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(pointsType), RevFeatureTypeBuilder.build(modifiedPointsType)); patch.addModifiedFeature(featureDiff); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); // TODO }
@Test public void testModifyFeatureAttributePatch() 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"); Geometry oldGeometry = (Geometry) points1.getProperty("pp").getValue(); Geometry newGeometry = new WKTReader2().read("POINT (2 2)"); GeometryAttributeDiff geomDiff = new GeometryAttributeDiff(oldGeometry, newGeometry); map.put(pointsType.getDescriptor("sp"), diff); map.put(pointsType.getDescriptor("pp"), geomDiff); FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureType.builder().type(pointsType).build(), RevFeatureType.builder().type(pointsType).build()); patch.addModifiedFeature(feaureDiff); testPatch(patch); }
@Test public void testAddFeatureAttributePatch() throws Exception { insert(points1); 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(pointsType).build(), RevFeatureType.builder().type(modifiedPointsType).build()); patch.addModifiedFeature(featureDiff); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); // TODO }
@Test public void testAddFeatureAttributePatch() throws Exception { 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(pointsType).build(), RevFeatureType.builder().type(modifiedPointsType).build()); patch.addModifiedFeature(featureDiff); patch.addFeatureType(RevFeatureType.builder().type(modifiedPointsType).build()); testPatch(patch); }
@Test public void testRemoveFeatureAttributePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.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); patch.addFeatureType(RevFeatureType.builder().type(pointsType).build()); testPatch(patch); }
@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); } }