use of sonia.scm.repository.ChangesetPagingResult in project scm-review-plugin by scm-manager.
the class BranchRevisionResolverTest method mockSingleChangeset.
private void mockSingleChangeset(String branch) throws IOException {
when(repositoryService.getLogCommand()).thenReturn(logCommandBuilder);
LogCommandBuilder subLogCommandBuilder = mock(LogCommandBuilder.class);
lenient().when(logCommandBuilder.setBranch(branch)).thenReturn(subLogCommandBuilder);
lenient().when(subLogCommandBuilder.setPagingStart(0)).thenReturn(subLogCommandBuilder);
lenient().when(subLogCommandBuilder.setPagingLimit(1)).thenReturn(subLogCommandBuilder);
Changeset changeset = new Changeset();
changeset.setId(branch + "Id");
lenient().when(subLogCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(1, singletonList(changeset)));
}
use of sonia.scm.repository.ChangesetPagingResult in project scm-review-plugin by scm-manager.
the class DefaultPullRequestServiceTest method mockChangesets.
private void mockChangesets(Changeset... changesets) throws IOException {
RepositoryService service = mock(RepositoryService.class);
lenient().when(repositoryService.create(any(Repository.class))).thenReturn(service);
LogCommandBuilder logCommandBuilder = mock(LogCommandBuilder.class, Mockito.RETURNS_SELF);
lenient().when(service.getLogCommand()).thenReturn(logCommandBuilder);
lenient().when(logCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(changesets.length, asList(changesets)));
}
use of sonia.scm.repository.ChangesetPagingResult in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method mockChangesets.
private void mockChangesets(String sourceBranch, String targetBranch, Changeset... changesets) throws IOException {
when(repositoryService.getLogCommand()).thenReturn(logCommandBuilder);
LogCommandBuilder subLogCommandBuilder = mock(LogCommandBuilder.class);
when(logCommandBuilder.setStartChangeset(sourceBranch)).thenReturn(subLogCommandBuilder);
when(subLogCommandBuilder.setAncestorChangeset(targetBranch)).thenReturn(subLogCommandBuilder);
when(subLogCommandBuilder.setPagingStart(0)).thenReturn(subLogCommandBuilder);
when(subLogCommandBuilder.setPagingLimit(1)).thenReturn(subLogCommandBuilder);
when(subLogCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(changesets.length, asList(changesets)));
}
use of sonia.scm.repository.ChangesetPagingResult in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method mockLogCommandForPullRequestCheck.
private void mockLogCommandForPullRequestCheck(List<Changeset> changesets) throws IOException {
when(repositoryServiceFactory.create(repository)).thenReturn(repositoryService);
when(repositoryService.getLogCommand()).thenReturn(logCommandBuilder);
when(logCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(0, changesets));
}
use of sonia.scm.repository.ChangesetPagingResult in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldNotEnrichCommitMessageWithMergerAsCoAuthor.
@Test
void shouldNotEnrichCommitMessageWithMergerAsCoAuthor() throws IOException {
mockUser("arthur", "Arthur Dent", "dent@hitchhiker.org");
when(mergeCommandBuilder.isSupported(MergeStrategy.SQUASH)).thenReturn(true);
when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
ImmutableList<Changeset> changesets = ImmutableList.of(new Changeset("1", 1L, new Person("Arthur Dent", "dent@hitchhiker.org"), "42\n\nCo-authored-by: Tricia McMillan <trillian@hitchhiker.org>"), new Changeset("2", 2L, new Person("Arthur Dent", "dent@hitchhiker.org"), "42\n\nCo-authored-by: Arthur Dent <dent@hitchhiker.org>"));
when(logCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(1, changesets));
PullRequest pullRequest = mockPullRequest("squash", "master", "1");
pullRequest.setAuthor("Arthur Dent");
MergeCommitDto mergeCommit = createMergeCommit(false);
mergeCommit.setCommitMessage("42");
service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.SQUASH, false);
verify(mergeCommandBuilder).setMessage("42\n\n" + "Co-authored-by: Tricia McMillan <trillian@hitchhiker.org>\n");
}
Aggregations