Search in sources :

Example 46 with WorkingTree

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());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 47 with WorkingTree

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());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) DiffOp(org.locationtech.geogig.api.porcelain.DiffOp) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 48 with WorkingTree

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());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) DiffOp(org.locationtech.geogig.api.porcelain.DiffOp) Patch(org.locationtech.geogig.api.plumbing.diff.Patch) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 49 with WorkingTree

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());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) NodeRef(org.locationtech.geogig.api.NodeRef) LsTreeOp(org.locationtech.geogig.api.plumbing.LsTreeOp) Test(org.junit.Test)

Example 50 with WorkingTree

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());
}
Also used : WorkingTree(org.locationtech.geogig.repository.WorkingTree) NodeRef(org.locationtech.geogig.api.NodeRef) RevObjectParse(org.locationtech.geogig.api.plumbing.RevObjectParse) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Aggregations

WorkingTree (org.locationtech.geogig.repository.WorkingTree)54 Test (org.junit.Test)32 AddOp (org.locationtech.geogig.api.porcelain.AddOp)25 List (java.util.List)18 ImmutableList (com.google.common.collect.ImmutableList)17 File (java.io.File)17 ArrayList (java.util.ArrayList)16 RevFeature (org.locationtech.geogig.api.RevFeature)15 Optional (com.google.common.base.Optional)12 SimpleFeature (org.opengis.feature.simple.SimpleFeature)12 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)11 NodeRef (org.locationtech.geogig.api.NodeRef)10 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)9 Name (org.opengis.feature.type.Name)9 GeoGIG (org.locationtech.geogig.api.GeoGIG)7 Node (org.locationtech.geogig.api.Node)7 ProgressListener (org.locationtech.geogig.api.ProgressListener)6 RevCommit (org.locationtech.geogig.api.RevCommit)6 Coordinate (com.vividsolutions.jts.geom.Coordinate)5 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)5