use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class RevertOpTest method testRevertOnlyCommit.
@Test
public void testRevertOnlyCommit() throws Exception {
insertAndAdd(points1);
RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c1.getId())).call();
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
RevTree headTree = repo.getTree(headTreeId.get());
Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
assertFalse(points1Node.isPresent());
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class RevertOpTest method testRevertEntireFeatureTypeTree.
@Test
public void testRevertEntireFeatureTypeTree() throws Exception {
insertAndAdd(points1);
RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
insertAndAdd(points2);
RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
insertAndAdd(points3);
RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
insertAndAdd(lines1);
RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();
geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c4.getId())).call();
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
RevTree headTree = repo.getTree(headTreeId.get());
Optional<NodeRef> lines1Node = geogig.command(FindTreeChild.class).setChildPath(NodeRef.appendChild(linesName, idL1)).setParent(headTree).call();
assertFalse(lines1Node.isPresent());
@SuppressWarnings("unused") Optional<NodeRef> linesNode = geogig.command(FindTreeChild.class).setChildPath(linesName).setParent(headTree).call();
// assertFalse(linesNode.isPresent());
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
log.next();
assertEquals(c4.getId(), log.next().getId());
assertEquals(c3.getId(), log.next().getId());
assertEquals(c2.getId(), log.next().getId());
assertEquals(c1.getId(), log.next().getId());
assertFalse(log.hasNext());
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class RevertOpTest method testRevertWithoutCommit.
@Test
public void testRevertWithoutCommit() throws Exception {
ObjectId oId1 = insertAndAdd(points1);
RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
insertAndAdd(points2);
RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
insertAndAdd(points1_modified);
RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1).call();
ObjectId oId3 = insertAndAdd(points3);
RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
deleteAndAdd(points3);
RevCommit c5 = geogig.command(CommitOp.class).setMessage("commit for deleted " + idP3).call();
// revert Points.2 add, Points.1 change, and Points.3 delete
geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).addCommit(Suppliers.ofInstance(c3.getId())).addCommit(Suppliers.ofInstance(c5.getId())).setCreateCommit(false).call();
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.WORK_HEAD).call();
final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
RevTree headTree = repo.getTree(headTreeId.get());
Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
assertTrue(points1Node.isPresent());
assertEquals(oId1, points1Node.get().getNode().getObjectId());
Optional<NodeRef> points2Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP2)).setParent(headTree).call();
assertFalse(points2Node.isPresent());
Optional<NodeRef> points3Node = geogig.command(FindTreeChild.class).setIndex(true).setChildPath(NodeRef.appendChild(pointsName, idP3)).setParent(headTree).call();
assertTrue(points3Node.isPresent());
assertEquals(oId3, points3Node.get().getNode().getObjectId());
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
// There should only the old commits.
assertEquals(c5.getId(), log.next().getId());
assertEquals(c4.getId(), log.next().getId());
assertEquals(c3.getId(), log.next().getId());
assertEquals(c2.getId(), log.next().getId());
assertEquals(c1.getId(), log.next().getId());
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class IndexTest method testWriteEmptyPathAddAll.
@Test
public void testWriteEmptyPathAddAll() throws Exception {
insert(lines1);
WorkingTree workingTree = geogig.getRepository().workingTree();
workingTree.createTypeTree(pointsName, pointsType);
List<NodeRef> workHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.WORK_HEAD).setStrategy(Strategy.DEPTHFIRST).call());
assertEquals(3, workHead.size());
Collection<NodeRef> filtered = Collections2.filter(workHead, new TreeNameFilter(pointsName));
assertEquals(1, filtered.size());
geogig.command(AddOp.class).call();
List<NodeRef> indexHead = toList(geogig.command(LsTreeOp.class).setReference(Ref.STAGE_HEAD).setStrategy(Strategy.DEPTHFIRST).call());
assertEquals(3, indexHead.size());
filtered = Collections2.filter(indexHead, new TreeNameFilter(pointsName));
assertEquals(1, filtered.size());
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class OSMImportOpTest method testImportMultipleRules.
@Test
public void testImportMultipleRules() {
final Mapping mapping;
final File data = new File(getClass().getResource("ways.xml").getFile());
{
final File mappingsFile = new File(getClass().getResource("../cli/commands/mapping_multiple_rules.json").getFile());
checkState(data.exists());
checkState(mappingsFile.exists());
mapping = Mapping.fromFile(mappingsFile.getAbsolutePath());
checkState(2 == mapping.getRules().size(), "expected 2 rules, got %s", mapping.getRules().size());
}
geogig.command(OSMImportOp.class).setDataSource(data.getAbsolutePath()).setMapping(mapping).setNoRaw(true).call();
WorkingTree workingTree = geogig.getContext().workingTree();
List<NodeRef> featureTypeTrees = workingTree.getFeatureTypeTrees();
assertEquals(2, featureTypeTrees.size());
Set<String> expectedNames = newHashSet("osm_roads", "osm_roads_main");
assertTrue(expectedNames.contains(featureTypeTrees.get(0).name()));
assertTrue(expectedNames.contains(featureTypeTrees.get(1).name()));
}
Aggregations