@Override protected void setUpInternal() throws Exception { featureType = RevFeatureTypeBuilder.build(pointsType); }
private Iterator<Feature> transformFeatures(SimpleFeatureType featureType, String path) { String refspec = Ref.WORK_HEAD + ":" + path; Iterator<NodeRef> oldFeatures = command(LsTreeOp.class).setReference(refspec) .setStrategy(Strategy.FEATURES_ONLY).call(); RevFeatureType revFeatureType = RevFeatureTypeBuilder.build(featureType); Iterator<Feature> transformedIterator = transformIterator(oldFeatures, revFeatureType); return transformedIterator; }
@Override protected void setUpInternal() throws Exception { insertAndAdd(points1, points2, points3); commit("inital"); SimpleFeatureType fullSchema = pointsType; RevFeatureType nativeType = RevFeatureTypeBuilder.build(fullSchema); Context actualContext = repo.context(); context = spy(actualContext); difftree = spy(context.command(DiffTree.class)); doReturn(difftree).when(context).command(eq(DiffTree.class)); NodeRef typeRef = context.workingTree().getFeatureTypeTrees().get(0); FeatureReaderBuilder b = FeatureReaderBuilder.builder(context, nativeType, typeRef); builder = spy(b); }
@Test public void testToString() { RevFeatureType featureType = RevFeatureTypeBuilder.build(linesType); String featureTypeString = featureType.toString(); assertEquals("FeatureType[" + featureType.getId().toString() + "; " + "sp: String, ip: Integer, pp: LineString]", featureTypeString); } }
protected void insert(Repository repo, Iterable<? extends Feature> features) throws Exception { WorkingTree workingTree = repo.workingTree(); FeatureType type = features.iterator().next().getType(); repo.objectDatabase().put(RevFeatureTypeBuilder.build(type)); final String treePath = type.getName().getLocalPart(); Iterable<FeatureInfo> featureInfos = Iterables.transform(features, (f) -> featureInfo(treePath, f)); workingTree.insert(featureInfos.iterator(), new DefaultProgressListener()); }
@Test public void testModifiedEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); RevFeatureType modifiedFeatureType = RevFeatureTypeBuilder.build(modifiedPointsType); patch.addFeatureType(featureType); patch.addFeatureType(modifiedFeatureType); patch.addAlteredTree( new FeatureTypeDiff(pointsName, featureType.getId(), modifiedFeatureType.getId())); testPatch(patch); }
@Test public void testAddEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, null, featureType.getId())); testPatch(patch); }
@Test public void testRemoveEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, featureType.getId(), null)); testPatch(patch); }
public FeatureInfo featureInfo(String treePath, Feature f) { final String path = NodeRef.appendChild(treePath, f.getIdentifier().getID()); RevFeature feature = RevFeatureBuilder.build(f); FeatureType type = f.getType(); RevFeatureType ftype = RevFeatureTypeBuilder.build(type); return FeatureInfo.insert(feature, ftype.getId(), path); }
@Test public void testConstructorAndAccessors() { RevFeatureType featureType = RevFeatureTypeBuilder.build(linesType); assertEquals(RevObject.TYPE.FEATURETYPE, featureType.getType()); assertEquals(linesType, featureType.type()); assertEquals(linesType.getName(), featureType.getName()); ArrayList<PropertyDescriptor> descriptors = Lists.newArrayList(linesType.getDescriptors()); // Collections.sort(descriptors, RevFeatureType.PROPERTY_ORDER); assertEquals(descriptors, featureType.descriptors()); }
@Test public void testRemoveFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addRemovedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); testPatch(patch); }
@Test public void testCreatePatchAddNewEmptyFeatureTypeToEmptyRepo() throws Exception { WorkingTree workingTree = geogig.getRepository().workingTree(); workingTree.createTypeTree(linesName, linesType); DiffOp op = geogig.command(DiffOp.class).setReportTrees(true); try (AutoCloseableIterator<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(RevFeatureTypeBuilder.build(linesType).getId(), patch.getAlteredTrees().get(0).getNewFeatureType()); assertEquals(1, patch.getFeatureTypes().size()); } }
@Test public void testAddFeaturePatch() throws Exception { Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addAddedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); testPatch(patch); }
protected FeatureInfo featureInfo(SimpleFeatureType type, String id, Object... values) { RevFeature feature = RevFeatureBuilder.build(feature(type, id, values)); RevFeatureType ftype = RevFeatureTypeBuilder.build(type); repo.objectDatabase().put(ftype); String path = NodeRef.appendChild(type.getName().getLocalPart(), id); return FeatureInfo.insert(feature, ftype.getId(), path); }
public FeatureInfo featureInfo(String treePath, Feature f) { final String path = NodeRef.appendChild(treePath, f.getIdentifier().getID()); RevFeature feature = RevFeatureBuilder.build(f); FeatureType type = f.getType(); RevFeatureType ftype = RevFeatureTypeBuilder.build(type); repo.objectDatabase().put(ftype); return FeatureInfo.insert(feature, ftype.getId(), path); }
@Test public void testAddEmptyFeatureTypePatch() throws Exception { Patch patch = new Patch(); RevFeatureType featureType = RevFeatureTypeBuilder.build(pointsType); patch.addFeatureType(featureType); patch.addAlteredTree(new FeatureTypeDiff(pointsName, null, featureType.getId())); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> typeTreeId = findTreeChild(root, pointsName); RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId()); assertNotNull(typeTree); assertEquals(featureType.getId(), typeTreeId.get().getMetadataId().get()); }
@Test public void testRemoveFeaturePatch() throws Exception { insert(points1); Patch patch = new Patch(); String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID()); patch.addRemovedFeature(path, RevFeatureBuilder.build(points1), RevFeatureTypeBuilder.build(pointsType)); geogig.command(ApplyPatchOp.class).setPatch(patch).call(); RevTree root = repo.workingTree().getTree(); assertNotNull(root); Optional<Node> featureBlobId = findTreeChild(root, path); assertFalse(featureBlobId.isPresent()); }
@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 testCommitAddsFeatureTypeToObjectDatabase() throws Exception { insertAndAdd(points1); ObjectId id = RevFeatureTypeBuilder.build(pointsType).getId(); geogig.command(AddOp.class).addPattern(".").call(); RevCommit commit = geogig.command(CommitOp.class).call(); assertNotNull(commit); RevFeatureType type = geogig.getRepository().objectDatabase().getFeatureType(id); assertEquals(id, type.getId()); }
protected ObjectId insert(Repository repo, Feature f) throws Exception { final WorkingTree workTree = repo.workingTree(); Name name = f.getType().getName(); String parentPath = name.getLocalPart(); RevFeatureType type = RevFeatureTypeBuilder.build(f.getType()); repo.objectDatabase().put(type); String path = NodeRef.appendChild(parentPath, f.getIdentifier().getID()); FeatureInfo fi = FeatureInfo.insert(RevFeatureBuilder.build(f), type.getId(), path); workTree.insert(fi); return fi.getFeature().getId(); }