private RevCommit commitAllowEmpty(String message) { return geogig.command(CommitOp.class).setAllowEmpty(true).call(); }
private RevCommit commitAllowEmpty(String message) { return geogig.command(CommitOp.class).setAllowEmpty(true).call(); }
private TestData commit(String commitMessage, boolean allowEmpty) { RevCommit commit = getContext().command(CommitOp.class).setAllowEmpty(allowEmpty) .setMessage(commitMessage).call(); LOG.debug(commit.toString()); return this; }
private TestData commit(String commitMessage, boolean allowEmpty) { RevCommit commit = getContext().command(CommitOp.class).setAllowEmpty(allowEmpty) .setMessage(commitMessage).call(); LOG.debug(commit.toString()); return this; }
private RevCommit createCommits(int numCommits, String branchName) { RevCommit commit = null; for (int i = 1; i <= numCommits; i++) { commit = geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit " + i + " in branch " + branchName).call(); } return commit; }
private RevCommit createCommits(int numCommits, String branchName) { RevCommit commit = null; for (int i = 1; i <= numCommits; i++) { commit = geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit " + i + " in branch " + branchName).call(); } return commit; }
@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); 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()); verify(listener1, times(1)).isCanceled(); verify(listener2, times(2)).isCanceled(); verify(listener3, times(3)).isCanceled(); }
@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); 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()); verify(listener1, times(1)).isCanceled(); verify(listener2, times(2)).isCanceled(); verify(listener3, times(3)).isCanceled(); }
@Test public void testNoCommitterEmail() throws Exception { injector.configDatabase().remove("user.email"); CommitOp commitCommand = geogig.command(CommitOp.class); exception.expect(IllegalStateException.class); commitCommand.setAllowEmpty(true).call(); }
@Test public void testNoCommitterName() throws Exception { injector.configDatabase().remove("user.name"); CommitOp commitCommand = geogig.command(CommitOp.class); exception.expect(IllegalStateException.class); commitCommand.setAllowEmpty(true).call(); }
@Test public void testNoCommitterName() throws Exception { injector.configDatabase().remove("user.name"); CommitOp commitCommand = geogig.command(CommitOp.class); exception.expect(IllegalStateException.class); commitCommand.setAllowEmpty(true).call(); }
@Test public void testCommitWithExplicitNullAuthorEmail() throws Exception { CommitOp commitCommand = geogig.command(CommitOp.class); commitCommand.setAuthor("John Doe", null); commitCommand.setAllowEmpty(true); RevCommit commit = commitCommand.call(); assertFalse(commit.getAuthor().getEmail().isPresent()); assertEquals("groldan", commit.getCommitter().getName().get()); assertEquals("groldan@boundlessgeo.com", commit.getCommitter().getEmail().get()); assertEquals("John Doe", commit.getAuthor().getName().get()); }
@Test public void testCommitWithExplicitNullAuthorEmail() throws Exception { CommitOp commitCommand = geogig.command(CommitOp.class); commitCommand.setAuthor("John Doe", null); commitCommand.setAllowEmpty(true); RevCommit commit = commitCommand.call(); assertFalse(commit.getAuthor().getEmail().isPresent()); assertEquals("groldan", commit.getCommitter().getName().get()); assertEquals("groldan@boundlessgeo.com", commit.getCommitter().getEmail().get()); assertEquals("John Doe", commit.getAuthor().getName().get()); }
@Test public void testNoCommitterEmail() throws Exception { injector.configDatabase().remove("user.email"); CommitOp commitCommand = geogig.command(CommitOp.class); exception.expect(IllegalStateException.class); commitCommand.setAllowEmpty(true).call(); }
@Test public void testEmptyCommit() throws Exception { 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); }
@Test public void testEmptyCommit() throws Exception { 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); }
private List<ObjectId> createBranches(int numBranches, int numCommits) { List<ObjectId> list = Lists.newArrayList(); for (int i = 1; i <= numBranches; i++) { String branchName = "branch" + Integer.toString(i); geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit before " + branchName).call(); geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName(branchName).call(); createCommits(numCommits / 2, branchName); geogig.command(CheckoutOp.class).setSource(Ref.MASTER).call(); geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit during " + branchName).call(); geogig.command(CheckoutOp.class).setSource(branchName).call(); RevCommit lastCommit = createCommits(numCommits / 2, branchName); geogig.command(CheckoutOp.class).setSource(Ref.MASTER).call(); list.add(lastCommit.getId()); } return list; }
private List<ObjectId> createBranches(int numBranches, int numCommits) { List<ObjectId> list = Lists.newArrayList(); for (int i = 1; i <= numBranches; i++) { String branchName = "branch" + Integer.toString(i); geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit before " + branchName).call(); geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName(branchName).call(); createCommits(numCommits / 2, branchName); geogig.command(CheckoutOp.class).setSource(Ref.MASTER).call(); geogig.command(CommitOp.class).setAllowEmpty(true) .setMessage("Commit during " + branchName).call(); geogig.command(CheckoutOp.class).setSource(branchName).call(); RevCommit lastCommit = createCommits(numCommits / 2, branchName); geogig.command(CheckoutOp.class).setSource(Ref.MASTER).call(); list.add(lastCommit.getId()); } return list; }
@Test public void testExplicitTimeStamp() throws Exception { CommitOp commitCommand = geogig.command(CommitOp.class); commitCommand.setAuthorTimestamp(1000L); commitCommand.setAuthorTimeZoneOffset(-3); commitCommand.setCommitterTimestamp(2000L); commitCommand.setCommitterTimeZoneOffset(+4); commitCommand.setAllowEmpty(true); RevCommit commit = commitCommand.call(); assertEquals(1000L, commit.getAuthor().getTimestamp()); assertEquals(-3, commit.getAuthor().getTimeZoneOffset()); assertEquals(2000L, commit.getCommitter().getTimestamp()); assertEquals(+4, commit.getCommitter().getTimeZoneOffset()); }
@Test public void testExplicitTimeStamp() throws Exception { CommitOp commitCommand = geogig.command(CommitOp.class); commitCommand.setAuthorTimestamp(1000L); commitCommand.setAuthorTimeZoneOffset(-3); commitCommand.setCommitterTimestamp(2000L); commitCommand.setCommitterTimeZoneOffset(+4); commitCommand.setAllowEmpty(true); RevCommit commit = commitCommand.call(); assertEquals(1000L, commit.getAuthor().getTimestamp()); assertEquals(-3, commit.getAuthor().getTimeZoneOffset()); assertEquals(2000L, commit.getCommitter().getTimestamp()); assertEquals(+4, commit.getCommitter().getTimeZoneOffset()); }