use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.
the class DiffOpTest method testReportTreesEmptyTree.
@Test
public void testReportTreesEmptyTree() throws Exception {
WorkingTree workingTree = geogig.getRepository().workingTree();
workingTree.createTypeTree(linesName, linesType);
List<DiffEntry> difflist = toList(diffOp.setReportTrees(true).setOldVersion(ObjectId.NULL).setNewVersion(Ref.WORK_HEAD).call());
assertNotNull(difflist);
assertEquals(1, difflist.size());
DiffEntry de = difflist.get(0);
assertNull(de.getOldObject());
assertNotNull(de.getNewObject());
assertEquals(linesName, de.newPath());
assertEquals(DiffEntry.ChangeType.ADDED, de.changeType());
assertEquals(ObjectId.NULL, de.oldObjectId());
assertFalse(de.getNewObject().getMetadataId().isNull());
}
use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.
the class CreatePatchOpTest method testCreatePatchAddNewEmptyFeatureTypeToEmptyRepo.
@Test
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());
}
use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.
the class CreatePatchOpTest method testCreatePatchRemoveEmptyFeatureType.
@Test
public void testCreatePatchRemoveEmptyFeatureType() throws Exception {
WorkingTree workingTree = geogig.getRepository().workingTree();
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());
}
use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.
the class IndexTest method testWriteEmptyPath.
@Test
public void testWriteEmptyPath() throws Exception {
WorkingTree workingTree = geogig.getRepository().workingTree();
workingTree.createTypeTree(pointsName, pointsType);
workingTree.createTypeTree(linesName, linesType);
List<NodeRef> workHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.WORK_HEAD).setStrategy(Strategy.DEPTHFIRST).call());
assertEquals(2, workHead.size());
Collection<NodeRef> filtered;
filtered = Collections2.filter(workHead, new TreeNameFilter(pointsName));
assertEquals(1, filtered.size());
filtered = Collections2.filter(workHead, new TreeNameFilter(linesName));
assertEquals(1, filtered.size());
geogig.command(AddOp.class).addPattern(pointsName).call();
List<NodeRef> indexHead;
indexHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.STAGE_HEAD).setStrategy(Strategy.DEPTHFIRST).call());
assertEquals(1, indexHead.size());
filtered = Collections2.filter(indexHead, new TreeNameFilter(pointsName));
assertEquals(1, filtered.size());
geogig.command(AddOp.class).addPattern(linesName).call();
indexHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.STAGE_HEAD).setStrategy(Strategy.DEPTHFIRST).call());
// Points and Lines
assertEquals(2, indexHead.size());
filtered = Collections2.filter(indexHead, new TreeNameFilter(linesName));
assertEquals(1, filtered.size());
}
use of org.locationtech.geogig.repository.WorkingTree in project GeoGig by boundlessgeo.
the class CommitOpTest method testCommitEmptyTreeOnEmptyRepo.
@Test
public void testCommitEmptyTreeOnEmptyRepo() throws Exception {
WorkingTree workingTree = geogig.getRepository().workingTree();
final String emptyTreeName = "emptyTree";
workingTree.createTypeTree(emptyTreeName, pointsType);
geogig.command(AddOp.class).addPattern(emptyTreeName).call();
CommitOp commitCommand = geogig.command(CommitOp.class);
RevCommit commit = commitCommand.call();
assertNotNull(commit);
RevTree head = geogig.command(RevObjectParse.class).setObjectId(commit.getTreeId()).call(RevTree.class).get();
Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setChildPath(emptyTreeName).setParent(head).call();
assertTrue(ref.isPresent());
}
Aggregations