Package org.locationtech.geogig.api.plumbing.diff

Examples of org.locationtech.geogig.api.plumbing.diff.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();
        Optional<?> newValue = Optional.fromNullable(points1B.getProperty("extra").getValue());
        GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue);
        map.put(modifiedPointsType.getDescriptor("extra"), diff);
        FeatureDiff featureDiff = new FeatureDiff(path, map, RevFeatureTypeImpl.build(pointsType),
                RevFeatureTypeImpl.build(modifiedPointsType));
        patch.addModifiedFeature(featureDiff);
        geogig.command(ApplyPatchOp.class).setPatch(patch).call();
        // TODO
    }
View Full Code Here


    }

    @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();
        Optional<?> oldValue = Optional.fromNullable(points1B.getProperty("extra").getValue());
        GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, null);
        map.put(modifiedPointsType.getDescriptor("extra"), diff);
        FeatureDiff featureDiff = new FeatureDiff(path, map,
                RevFeatureTypeImpl.build(modifiedPointsType), RevFeatureTypeImpl.build(pointsType));
        patch.addModifiedFeature(featureDiff);
        try {
            geogig.command(ApplyPatchOp.class).setPatch(patch).call();
            fail();
        } catch (CannotApplyPatchException e) {
            assertTrue(true);
View Full Code Here

    }

    @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();
        Optional<?> newValue = Optional.fromNullable(points1B.getProperty("extra").getValue());
        GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(null, newValue);
        map.put(modifiedPointsType.getDescriptor("extra"), diff);
        FeatureDiff featureDiff = new FeatureDiff(path, map,
                RevFeatureTypeImpl.build(modifiedPointsType), RevFeatureTypeImpl.build(modifiedPointsType));
        patch.addModifiedFeature(featureDiff);
        try {
            geogig.command(ApplyPatchOp.class).setPatch(patch).call();
            fail();
        } catch (CannotApplyPatchException e) {
            assertTrue(true);
View Full Code Here

        insert(modifiedFeature);
        insert(points3);
        delete(points2);

        Iterator<DiffEntry> diffs = geogig.command(DiffOp.class).call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();

        assertEquals(3, patch.count());
        assertEquals(1, patch.getAddedFeatures().size());
        assertEquals(1, patch.getRemovedFeatures().size());
        assertEquals(1, patch.getModifiedFeatures().size());
        assertEquals(RevFeatureTypeImpl.build(pointsType), patch.getFeatureTypes().get(0));
        assertEquals(NodeRef.appendChild(pointsName, idP2), patch.getRemovedFeatures().get(0)
                .getPath());
        assertEquals(NodeRef.appendChild(pointsName, idP3), patch.getAddedFeatures().get(0)
                .getPath());

    }
View Full Code Here

        deleteAndAdd(points2);
        delete(points3);
        DiffOp op = geogig.command(DiffOp.class);
        op.setCompareIndex(true);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();

        assertEquals(3, patch.count());
        assertEquals(1, patch.getAddedFeatures().size());
        assertEquals(1, patch.getRemovedFeatures().size());
        assertEquals(1, patch.getModifiedFeatures().size());
        assertEquals(RevFeatureTypeImpl.build(pointsType), patch.getFeatureTypes().get(0));
        assertEquals(NodeRef.appendChild(pointsName, idP2), patch.getRemovedFeatures().get(0)
                .getPath());
        assertEquals(NodeRef.appendChild(pointsName, idP3), patch.getAddedFeatures().get(0)
                .getPath());
    }
View Full Code Here

    @Test
    public void testCreatePatchWithNoChanges() throws Exception {
        insertAndAdd(points1, points2);
        geogig.command(CommitOp.class).setAll(true).call();
        Iterator<DiffEntry> diffs = geogig.command(DiffOp.class).call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(0, patch.count());
    }
View Full Code Here

    @Test
    public void testCreatePatchAddNewFeatureToEmptyRepo() throws Exception {
        insert(points1);
        DiffOp op = geogig.command(DiffOp.class);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAddedFeatures().size());
    }
View Full Code Here

    public void testCreatePatchAddNewEmptyFeatureTypeToEmptyRepo() throws Exception {
        WorkingTree workingTree = geogig.getRepository().workingTree();
        workingTree.createTypeTree(linesName, linesType);
        DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAlteredTrees().size());
        assertEquals(ObjectId.NULL, patch.getAlteredTrees().get(0).getOldFeatureType());
        assertEquals(RevFeatureTypeImpl.build(linesType).getId(), patch.getAlteredTrees().get(0)
                .getNewFeatureType());
        assertEquals(1, patch.getFeatureTypes().size());
    }
View Full Code Here

        workingTree.createTypeTree(linesName, linesType);
        geogig.command(AddOp.class).setUpdateOnly(false).call();
        workingTree.delete(linesName);
        DiffOp op = geogig.command(DiffOp.class).setReportTrees(true);
        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAlteredTrees().size());
        assertEquals(RevFeatureTypeImpl.build(linesType).getId(), patch.getAlteredTrees().get(0)
                .getOldFeatureType());
        assertEquals(ObjectId.NULL, patch.getAlteredTrees().get(0).getNewFeatureType());
        assertEquals(1, patch.getFeatureTypes().size());
    }
View Full Code Here

        insertAndAdd(points1, points2);
        geogig.getRepository().workingTree().updateTypeTree(pointsName, modifiedPointsType);

        Iterator<DiffEntry> diffs = op.call();
        Patch patch = geogig.command(CreatePatchOp.class).setDiffs(diffs).call();
        assertEquals(1, patch.getAlteredTrees().size());
        assertEquals(RevFeatureTypeImpl.build(pointsType).getId(), patch.getAlteredTrees().get(0)
                .getOldFeatureType());
        assertEquals(RevFeatureTypeImpl.build(modifiedPointsType).getId(),
                patch.getAlteredTrees().get(0).getNewFeatureType());
        assertEquals(2, patch.getFeatureTypes().size());
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.plumbing.diff.Patch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.