Search in sources :

Example 56 with NodeRef

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

the class WriteTree2Test method testDeletes.

@Test
public void testDeletes() {
    leftTree = createHeadTree(//
    repoTree("roads", EMPTY_ID, null, 0), //
    repoTree("roads/highways", "a2", "d1", 10), //
    repoTree("roads/streets", "a3", "d2", 10), //
    repoTree("buildings", EMPTY_ID, null, 0), //
    repoTree("buildings/stores", "a5", "d3", 5), //
    repoTree("buildings/unknown", "a6", "d4", 5), //
    repoTree("buildings/towers", "a7", "d5", 5));
    rightTree = createStageHeadTree(//
    indexTree("roads", EMPTY_ID, null, 0), //
    indexTree("roads/highways", "a2", "d1", 10), //
    indexTree("buildings", EMPTY_ID, null, 0), //
    indexTree("buildings/stores", "a5", "d31", 5));
    final ObjectId newRepoRoot = command.call();
    assertNotNull(newRepoRoot);
    // check all blobs have been moved from the index to the object database
    verifyRepositoryTree(NodeRef.ROOT, newRepoRoot);
    ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot);
    assertEquals(set("roads", "roads/highways", "buildings", "buildings/stores"), refsByPath.keySet());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Test(org.junit.Test)

Example 57 with NodeRef

use of org.locationtech.geogig.api.NodeRef 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 58 with NodeRef

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

the class WriteTree2Test method testNoChanges.

@Test
public void testNoChanges() {
    leftTree = createHeadTree(//
    repoTree("buildings", EMPTY_ID, null, 0), //
    repoTree("buildings/stores", "a5", "d3", 5), //
    repoTree("buildings/unknown", "a6", "d4", 5), //
    repoTree("buildings/towers", "a7", "d5", 5));
    rightTree = createStageHeadTree(//
    repoTree("buildings", EMPTY_ID, null, 0), //
    repoTree("buildings/stores", "a5", "d3", 5), //
    repoTree("buildings/unknown", "a6", "d4", 5), //
    repoTree("buildings/towers", "a7", "d5", 5));
    ObjectId newRepoRoot = command.call();
    assertNotNull(newRepoRoot);
    // check all blobs have been moved from the index to the object database
    verifyRepositoryTree(NodeRef.ROOT, newRepoRoot);
    ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot);
    assertEquals(4, refsByPath.size());
    Set<String> expected = set("buildings", "buildings/stores", "buildings/unknown", "buildings/towers");
    assertEquals(expected, refsByPath.keySet());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Test(org.junit.Test)

Example 59 with NodeRef

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

the class WriteTree2Test method testMetadataIdChangeOnly.

@Test
public void testMetadataIdChangeOnly() {
    leftTree = createHeadTree(//
    repoTree("buildings", EMPTY_ID, null, 0), // old md id is d3
    repoTree("buildings/stores", "a5", "d3", 5));
    rightTree = createStageHeadTree(//
    indexTree("buildings", EMPTY_ID, null, 0), // new md id is d31
    indexTree("buildings/stores", "a5", "d31", 5));
    ObjectId newRepoRoot = command.call();
    assertNotNull(newRepoRoot);
    // check all blobs have been moved from the index to the object database
    verifyRepositoryTree(NodeRef.ROOT, newRepoRoot);
    ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot);
    assertEquals(set("buildings", "buildings/stores"), refsByPath.keySet());
    assertEquals(id("d31"), refsByPath.get("buildings/stores").getMetadataId());
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Test(org.junit.Test)

Example 60 with NodeRef

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

the class WriteTree2Test method testRename.

@Test
public void testRename() {
    leftTree = createHeadTree(//
    repoTree("roads", EMPTY_ID, null, 0));
    rightTree = createStageHeadTree(//
    indexTree("roadsRenamed", EMPTY_ID, null, 0));
    ObjectId newRepoRoot = command.call();
    assertNotNull(newRepoRoot);
    // check all blobs have been moved from the index to the object database
    verifyRepositoryTree(NodeRef.ROOT, newRepoRoot);
    ImmutableMap<String, NodeRef> refsByPath = getTreeRefsByPath(newRepoRoot);
    assertEquals(1, refsByPath.size());
    assertTrue(refsByPath.containsKey("roadsRenamed"));
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Test(org.junit.Test)

Aggregations

NodeRef (org.locationtech.geogig.api.NodeRef)161 ObjectId (org.locationtech.geogig.api.ObjectId)91 RevTree (org.locationtech.geogig.api.RevTree)67 Test (org.junit.Test)62 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)40 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)27 RevFeature (org.locationtech.geogig.api.RevFeature)25 Node (org.locationtech.geogig.api.Node)24 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)24 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)23 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)22 RevObject (org.locationtech.geogig.api.RevObject)21 RevCommit (org.locationtech.geogig.api.RevCommit)19 Map (java.util.Map)15 SimpleFeature (org.opengis.feature.simple.SimpleFeature)15 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)14 Feature (org.opengis.feature.Feature)13 Optional (com.google.common.base.Optional)12 GeoGIG (org.locationtech.geogig.api.GeoGIG)11 LsTreeOp (org.locationtech.geogig.api.plumbing.LsTreeOp)11