Search in sources :

Example 71 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class WriteBackTest method testPreserveMetadataId.

@Test
public void testPreserveMetadataId() {
    RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
    RevTree tree = new RevTreeBuilder(odb).put(blob("blob")).build();
    final ObjectId treeMetadataId = ObjectId.forString("fakeMdId");
    ObjectId newRootId = writeBack.setAncestor(oldRoot).setChildPath("level1/level2").setTree(tree).setMetadataId(treeMetadataId).call();
    Optional<NodeRef> ref;
    DepthSearch depthSearch = new DepthSearch(odb);
    ref = depthSearch.find(newRootId, "level1/level2");
    assertTrue(ref.isPresent());
    assertTrue(ref.get().getNode().getMetadataId().isPresent());
    assertFalse(ref.get().getNode().getMetadataId().get().isNull());
    assertEquals(treeMetadataId, ref.get().getNode().getMetadataId().get());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) DepthSearch(org.locationtech.geogig.repository.DepthSearch) ObjectId(org.locationtech.geogig.api.ObjectId) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 72 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class WriteTree2Test method forceTreeId.

private RevTree forceTreeId(RevTreeBuilder b, ObjectId treeId) {
    RevTree tree = b.build();
    RevTree fakenId = RevTreeImpl.create(treeId, tree.size(), tree);
    return fakenId;
}
Also used : RevTree(org.locationtech.geogig.api.RevTree)

Example 73 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class DiffCountConsumerTest method depth.

private int depth(RevTree deepTree, int currDepth) {
    if (!deepTree.buckets().isPresent()) {
        return currDepth;
    }
    int depth = currDepth;
    for (Bucket bucket : deepTree.buckets().get().values()) {
        RevTree bucketTree = odb.get(bucket.id(), RevTree.class);
        int d = depth(bucketTree, currDepth + 1);
        depth = Math.max(depth, d);
    }
    return depth;
}
Also used : Bucket(org.locationtech.geogig.api.Bucket) RevTree(org.locationtech.geogig.api.RevTree)

Example 74 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class WriteBackTest method testSiblingsNested.

@Test
public void testSiblingsNested() {
    RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
    RevTree tree1 = new RevTreeBuilder(odb).put(blob("blob")).build();
    RevTree tree2 = new RevTreeBuilder(odb).put(blob("blob")).build();
    ObjectId newRootId1 = writeBack.setAncestor(oldRoot).setChildPath("subtree1/level2").setTree(tree1).call();
    ObjectId newRootId2 = writeBack.setAncestor(odb.getTree(newRootId1).builder(odb)).setChildPath("subtree2/level2/level3").setTree(tree2).call();
    // created the intermediate tree node?
    DepthSearch depthSearch = new DepthSearch(odb);
    assertTrue(depthSearch.find(newRootId2, "subtree1").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree1/level2").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree1/level2/blob").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2/level2").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3/blob").isPresent());
}
Also used : DepthSearch(org.locationtech.geogig.repository.DepthSearch) ObjectId(org.locationtech.geogig.api.ObjectId) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 75 with RevTree

use of org.locationtech.geogig.api.RevTree in project GeoGig by boundlessgeo.

the class DiffCountConsumerTest method testChildrenChildrenNestedTrees.

@Test
public void testChildrenChildrenNestedTrees() {
    RevTreeBuilder rootBuilder = new RevTreeBuilder(odb, childrenFeatureTypesTree);
    childTree1.put(featureRef("tree1", 1000));
    createFeatureTypesTree(rootBuilder, "tree1", childTree1);
    RevTree newRoot = rootBuilder.build();
    assertEquals(1, count(childrenFeatureTypesTree, newRoot).featureCount());
    childTree2.remove("tree2/2");
    createFeatureTypesTree(rootBuilder, "tree2", childTree2);
    newRoot = rootBuilder.build();
    assertEquals(2, count(childrenFeatureTypesTree, newRoot).featureCount());
    childTree2.put(Node.create("tree2/1", FAKE_FEATURE_ID_CHANGED, ObjectId.NULL, TYPE.FEATURE, null));
    createFeatureTypesTree(rootBuilder, "tree2", childTree2);
    newRoot = rootBuilder.build();
    assertEquals(3, count(childrenFeatureTypesTree, newRoot).featureCount());
}
Also used : RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Aggregations

RevTree (org.locationtech.geogig.api.RevTree)214 Test (org.junit.Test)120 ObjectId (org.locationtech.geogig.api.ObjectId)91 NodeRef (org.locationtech.geogig.api.NodeRef)73 Node (org.locationtech.geogig.api.Node)56 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)47 RevCommit (org.locationtech.geogig.api.RevCommit)36 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)29 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)27 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)24 RevObject (org.locationtech.geogig.api.RevObject)21 RevFeature (org.locationtech.geogig.api.RevFeature)18 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)18 Bucket (org.locationtech.geogig.api.Bucket)17 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)17 File (java.io.File)16 Ref (org.locationtech.geogig.api.Ref)16 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)15 GeoGIG (org.locationtech.geogig.api.GeoGIG)14 OSMImportOp (org.locationtech.geogig.osm.internal.OSMImportOp)14