use of org.locationtech.geogig.api.porcelain.CommitOp in project GeoGig by boundlessgeo.
the class CommitOpTest method testEmptyCommit.
@Test
public void testEmptyCommit() throws Exception {
try {
geogig.command(AddOp.class).addPattern(".").call();
geogig.command(CommitOp.class).call();
fail("expected NothingToCommitException");
} catch (NothingToCommitException e) {
assertTrue(true);
}
CommitOp commitCommand = geogig.command(CommitOp.class);
RevCommit commit = commitCommand.setAllowEmpty(true).call();
assertNotNull(commit);
assertNotNull(commit.getParentIds());
assertEquals(0, commit.getParentIds().size());
assertFalse(commit.parentN(0).isPresent());
assertNotNull(commit.getId());
ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
assertEquals(commit.getId(), commitId);
}
use of org.locationtech.geogig.api.porcelain.CommitOp in project GeoGig by boundlessgeo.
the class CommitOpTest method testNoCommitterName.
@Test
public void testNoCommitterName() throws Exception {
try {
geogig.command(AddOp.class).addPattern(".").call();
geogig.command(CommitOp.class).call();
fail("expected NothingToCommitException");
} catch (NothingToCommitException e) {
assertTrue(true);
}
injector.configDatabase().remove("user.name");
CommitOp commitCommand = geogig.command(CommitOp.class);
exception.expect(IllegalStateException.class);
commitCommand.setAllowEmpty(true).call();
}
use of org.locationtech.geogig.api.porcelain.CommitOp in project GeoGig by boundlessgeo.
the class CommitOpTest method testCommitWithAllOptionAndPaths.
@Test
public void testCommitWithAllOptionAndPaths() throws Exception {
try {
geogig.command(AddOp.class).addPattern(".").call();
geogig.command(CommitOp.class).call();
fail("expected NothingToCommitException");
} catch (NothingToCommitException e) {
assertTrue(true);
}
insertAndAdd(points1);
geogig.command(AddOp.class).addPattern(".").call();
RevCommit commit = geogig.command(CommitOp.class).call();
ObjectId oid = insertAndAdd(points1_modified);
insert(points2);
insert(lines1);
CommitOp commitCommand = geogig.command(CommitOp.class);
commit = commitCommand.setPathFilters(ImmutableList.of(pointsName)).setAll(true).call();
assertNotNull(commit);
assertNotNull(commit.getParentIds());
assertEquals(1, commit.getParentIds().size());
assertNotNull(commit.getId());
ObjectId treeId = commit.getTreeId();
assertNotNull(treeId);
RevTree root = repo.getTree(treeId);
assertNotNull(root);
Optional<Node> linesTreeId = repo.getTreeChild(root, linesName);
assertFalse(linesTreeId.isPresent());
Optional<Node> typeTreeId = repo.getTreeChild(root, pointsName);
assertTrue(typeTreeId.isPresent());
RevTree typeTree = repo.getTree(typeTreeId.get().getObjectId());
assertNotNull(typeTree);
String featureId = points1.getIdentifier().getID();
Optional<Node> featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
assertTrue(featureBlobId.isPresent());
assertEquals(oid, featureBlobId.get().getObjectId());
featureId = points2.getIdentifier().getID();
featureBlobId = repo.getTreeChild(root, NodeRef.appendChild(pointsName, featureId));
assertFalse(featureBlobId.isPresent());
ObjectId commitId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call().get();
assertEquals(commit.getId(), commitId);
}
use of org.locationtech.geogig.api.porcelain.CommitOp in project GeoGig by boundlessgeo.
the class CommitOpTest method testNoCommitterEmail.
@Test
public void testNoCommitterEmail() throws Exception {
try {
geogig.command(AddOp.class).addPattern(".").call();
geogig.command(CommitOp.class).call();
fail("expected NothingToCommitException");
} catch (NothingToCommitException e) {
assertTrue(true);
}
injector.configDatabase().remove("user.email");
CommitOp commitCommand = geogig.command(CommitOp.class);
exception.expect(IllegalStateException.class);
commitCommand.setAllowEmpty(true).call();
}
use of org.locationtech.geogig.api.porcelain.CommitOp in project GeoGig by boundlessgeo.
the class CommitOpTest method testCancel.
@Test
public void testCancel() throws Exception {
ProgressListener listener1 = mock(ProgressListener.class);
when(listener1.isCanceled()).thenReturn(true);
ProgressListener listener2 = mock(ProgressListener.class);
when(listener2.isCanceled()).thenReturn(false, true);
ProgressListener listener3 = mock(ProgressListener.class);
when(listener3.isCanceled()).thenReturn(false, false, true);
try {
geogig.command(AddOp.class).addPattern(".").call();
geogig.command(CommitOp.class).call();
fail("expected NothingToCommitException");
} catch (NothingToCommitException e) {
assertTrue(true);
}
CommitOp commitCommand1 = geogig.command(CommitOp.class);
commitCommand1.setProgressListener(listener1);
assertNull(commitCommand1.setAllowEmpty(true).call());
CommitOp commitCommand2 = geogig.command(CommitOp.class);
commitCommand2.setProgressListener(listener2);
assertNull(commitCommand2.setAllowEmpty(true).call());
CommitOp commitCommand3 = geogig.command(CommitOp.class);
commitCommand3.setProgressListener(listener3);
assertNull(commitCommand3.setAllowEmpty(true).call());
}
Aggregations