Search in sources :

Example 81 with RevTree

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

the class PostOrderDiffWalkTest method testSameChildTree.

@Test
public void testSameChildTree() {
    RevTree left = createFeaturesTree(leftSource, "f", 10).build();
    RevTree right = left;
    PostOrderDiffWalk visitor = new PostOrderDiffWalk(left, right, leftSource, rightSource);
    Consumer consumer = mock(Consumer.class);
    visitor.walk(consumer);
    verifyNoMoreInteractions(consumer);
}
Also used : Consumer(org.locationtech.geogig.api.plumbing.diff.PostOrderDiffWalk.Consumer) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 82 with RevTree

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

the class RevTreeBuilderTest method testNodeOrderPassSplitThreshold.

@Test
public void testNodeOrderPassSplitThreshold() {
    final int splitThreshold = RevTree.NORMALIZED_SIZE_LIMIT;
    List<Node> expectedOrder = nodes(splitThreshold + 1);
    Collections.sort(expectedOrder, new NodeStorageOrder());
    final List<Node> flat = expectedOrder.subList(0, splitThreshold);
    RevTreeBuilder flatTreeBuilder = new RevTreeBuilder(odb);
    RevTreeBuilder bucketTreeBuilder = new RevTreeBuilder(odb);
    for (Node n : flat) {
        flatTreeBuilder.put(n);
        bucketTreeBuilder.put(n);
    }
    bucketTreeBuilder.put(expectedOrder.get(expectedOrder.size() - 1));
    RevTree flatTree = flatTreeBuilder.build();
    RevTree bucketTree = bucketTreeBuilder.build();
    assertFalse(flatTree.buckets().isPresent());
    assertTrue(bucketTree.buckets().isPresent());
    odb.put(flatTree);
    odb.put(bucketTree);
    List<Node> flatNodes = lstree(flatTree);
    assertEquals(flat, flatNodes);
    List<Node> splitNodes = lstree(bucketTree);
    assertEquals(expectedOrder, splitNodes);
}
Also used : Node(org.locationtech.geogig.api.Node) NodeStorageOrder(org.locationtech.geogig.storage.NodeStorageOrder) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 83 with RevTree

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

the class ImportOpTest method testImportTable.

@Test
public void testImportTable() throws Exception {
    ImportOp importOp = geogig.command(ImportOp.class);
    importOp.setDataStore(TestHelper.createTestFactory().createDataStore(null));
    importOp.setAll(false);
    importOp.setTable("table1");
    RevTree newWorkingTree = importOp.call();
    Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature1").setIndex(true).call();
    assertTrue(ref.isPresent());
    ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature2").setIndex(true).call();
    assertTrue(ref.isPresent());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 84 with RevTree

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

the class ImportOpTest method testImportAll.

@Test
public void testImportAll() throws Exception {
    ImportOp importOp = geogig.command(ImportOp.class);
    importOp.setDataStore(TestHelper.createTestFactory().createDataStore(null));
    importOp.setAll(true);
    RevTree newWorkingTree = importOp.call();
    Optional<NodeRef> ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature1").setIndex(true).call();
    assertTrue(ref.isPresent());
    ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table1/feature2").setIndex(true).call();
    assertTrue(ref.isPresent());
    ref = geogig.command(FindTreeChild.class).setParent(newWorkingTree).setChildPath("table2/feature3").setIndex(true).call();
    assertTrue(ref.isPresent());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 85 with RevTree

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

the class OSMMapTest method testMappingWithPolygons.

@Test
public void testMappingWithPolygons() throws Exception {
    // test a mapping with a a mapping rule that uses the polygon geometry type
    String filename = OSMImportOp.class.getResource("closed_ways.xml").getFile();
    File file = new File(filename);
    cli.execute("osm", "import", file.getAbsolutePath());
    cli.execute("add");
    cli.execute("commit", "-m", "message");
    Optional<RevTree> tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:node").call(RevTree.class);
    assertTrue(tree.isPresent());
    assertTrue(tree.get().size() > 0);
    tree = cli.getGeogig().command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
    assertTrue(tree.isPresent());
    assertTrue(tree.get().size() > 0);
    String mappingFilename = OSMMap.class.getResource("polygons_mapping.json").getFile();
    File mappingFile = new File(mappingFilename);
    cli.execute("osm", "map", mappingFile.getAbsolutePath());
    Iterator<NodeRef> iter = cli.getGeogig().command(LsTreeOp.class).setReference("HEAD:areas").call();
    assertTrue(iter.hasNext());
    Optional<RevFeatureType> ft = cli.getGeogig().command(ResolveFeatureType.class).setRefSpec("HEAD:" + iter.next().path()).call();
    assertTrue(ft.isPresent());
    assertEquals(Polygon.class, ft.get().sortedDescriptors().get(1).getType().getBinding());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) OSMImportOp(org.locationtech.geogig.osm.internal.OSMImportOp) RevObjectParse(org.locationtech.geogig.api.plumbing.RevObjectParse) File(java.io.File) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) 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