@Test
public void testMultipleCommits() throws Exception {
// insert and commit points1
final ObjectId oId1_1 = insertAndAdd(points1);
geogig.command(AddOp.class).call();
final RevCommit commit1 = geogig.command(CommitOp.class).call();
{
assertCommit(commit1, null, null, null);
// check points1 is there
assertEquals(oId1_1, repo.getRootTreeChild(appendChild(pointsName, idP1)).get()
.getObjectId());
// and check the objects were actually copied
assertNotNull(repo.objectDatabase().get(oId1_1));
}
// insert and commit points2, points3 and lines1
final ObjectId oId1_2 = insertAndAdd(points2);
final ObjectId oId1_3 = insertAndAdd(points3);
final ObjectId oId2_1 = insertAndAdd(lines1);
geogig.command(AddOp.class).call();
final RevCommit commit2 = geogig.command(CommitOp.class).setMessage("msg").call();
{
assertCommit(commit2, commit1.getId(), "groldan", "msg");
// repo.getHeadTree().accept(
// new PrintVisitor(repo.objectDatabase(), new PrintWriter(System.out)));
// check points2, points3 and lines1
assertEquals(oId1_2, repo.getRootTreeChild(appendChild(pointsName, idP2)).get()
.getObjectId());
assertEquals(oId1_3, repo.getRootTreeChild(appendChild(pointsName, idP3)).get()
.getObjectId());
assertEquals(oId2_1, repo.getRootTreeChild(appendChild(linesName, idL1)).get()
.getObjectId());
// and check the objects were actually copied
assertNotNull(repo.objectDatabase().get(oId1_2));
assertNotNull(repo.objectDatabase().get(oId1_3));
assertNotNull(repo.objectDatabase().get(oId2_1));
// as well as feature1_1 from the previous commit
assertEquals(oId1_1, repo.getRootTreeChild(appendChild(pointsName, idP1)).get()
.getObjectId());
}
// delete feature1_1, feature1_3, and feature2_1
assertTrue(deleteAndAdd(points1));
assertTrue(deleteAndAdd(points3));
assertTrue(deleteAndAdd(lines1));
// and insert feature2_2
final ObjectId oId2_2 = insertAndAdd(lines2);
geogig.command(AddOp.class).call();
final RevCommit commit3 = geogig.command(CommitOp.class).call();
{
assertCommit(commit3, commit2.getId(), "groldan", null);