use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class IndexTest method testWriteTree.
@Test
public void testWriteTree() throws Exception {
insertAndAdd(points1);
insertAndAdd(lines1);
// this new root tree must exist on the repo db, but is not set as the current head. In
// fact, it is headless, as there's no commit pointing to it. CommitOp does that.
ObjectId newRootTreeId = geogig.command(WriteTree.class).setOldRoot(tree(repo.getHead().get().getObjectId())).call();
assertNotNull(newRootTreeId);
assertFalse(repo.getRootTreeId().equals(newRootTreeId));
// but the index staged root shall be pointing to it
// assertEquals(newRootTreeId, index.getStaged().getId());
RevTree tree = repo.getTree(newRootTreeId);
// assertEquals(2, tree.size().intValue());
String path = appendChild(pointsName, points1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(tree).setChildPath(path).call().isPresent());
path = appendChild(linesName, lines1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(tree).setChildPath(path).call().isPresent());
// simulate a commit so the repo head points to this new tree
ObjectInserter objectInserter = repo.newObjectInserter();
List<ObjectId> parents = ImmutableList.of();
RevCommit commit = new CommitBuilder(geogig.getPlatform()).setTreeId(newRootTreeId).setParentIds(parents).build();
ObjectId commitId = commit.getId();
objectInserter.insert(commit);
Optional<Ref> newHead = geogig.command(UpdateRef.class).setName("refs/heads/master").setNewValue(commitId).call();
assertTrue(newHead.isPresent());
WorkingTree workTree = repo.workingTree();
workTree.delete(linesName, lines1.getIdentifier().getID());
geogig.command(AddOp.class).call();
// newRootTreeId
newRootTreeId = geogig.command(WriteTree2.class).setOldRoot(tree(newRootTreeId)).call();
// =
// index.writeTree(newRootTreeId,
// new
// NullProgressListener());
assertNotNull(newRootTreeId);
assertFalse(repo.getRootTreeId().equals(newRootTreeId));
tree = repo.getTree(newRootTreeId);
path = appendChild(pointsName, points1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(tree).setChildPath(path).call().isPresent());
path = appendChild(linesName, lines1.getIdentifier().getID());
assertFalse(repo.command(FindTreeChild.class).setParent(tree).setChildPath(path).call().isPresent());
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class IndexTest method testAddMultiple.
@Test
public void testAddMultiple() throws Exception {
ObjectId oId1 = insert(points1);
ObjectId oId2 = insert(points2);
assertNotNull(oId1);
assertNotNull(oId2);
assertFalse(index.findStaged(appendChild(pointsName, idP1)).isPresent());
assertFalse(index.findStaged(appendChild(pointsName, idP2)).isPresent());
assertEquals(oId1, repo.workingTree().findUnstaged(appendChild(pointsName, idP1)).get().getObjectId());
assertEquals(oId2, repo.workingTree().findUnstaged(appendChild(pointsName, idP2)).get().getObjectId());
geogig.command(AddOp.class).call();
assertEquals(oId1, index.findStaged(appendChild(pointsName, idP1)).get().getObjectId());
assertEquals(oId2, index.findStaged(appendChild(pointsName, idP2)).get().getObjectId());
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class IndexTest method testInsertIdenticalObjects.
// two features with the same content and different fid should point to the same object
@Test
public void testInsertIdenticalObjects() throws Exception {
ObjectId oId1 = insertAndAdd(points1);
Feature equalContentFeature = feature(pointsType, "DifferentId", ((SimpleFeature) points1).getAttributes().toArray());
ObjectId oId2 = insertAndAdd(equalContentFeature);
// BLOBS.print(repo.getRawObject(insertedId1), System.err);
// BLOBS.print(repo.getRawObject(insertedId2), System.err);
assertNotNull(oId1);
assertNotNull(oId2);
assertEquals(oId1, oId2);
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class IndexTest method testInsertNonEqualObjects.
// two features with different content should point to different objects
@Test
public void testInsertNonEqualObjects() throws Exception {
ObjectId oId1 = insertAndAdd(points1);
ObjectId oId2 = insertAndAdd(points2);
assertNotNull(oId1);
assertNotNull(oId2);
assertFalse(oId1.equals(oId2));
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class RefDatabaseTest method testPutGetRef.
@Test
public void testPutGetRef() {
byte[] raw = new byte[20];
Arrays.fill(raw, (byte) 1);
ObjectId oid = new ObjectId(raw);
assertEquals(ObjectId.NULL.toString(), refDb.getRef(Ref.MASTER));
refDb.putRef(Ref.MASTER, oid.toString());
assertEquals(oid.toString(), refDb.getRef(Ref.MASTER));
}
Aggregations