Search in sources :

Example 1 with ChangesetPagingResult

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)));
}
Also used : ChangesetPagingResult(sonia.scm.repository.ChangesetPagingResult) LogCommandBuilder(sonia.scm.repository.api.LogCommandBuilder) Changeset(sonia.scm.repository.Changeset)

Example 2 with ChangesetPagingResult

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)));
}
Also used : Repository(sonia.scm.repository.Repository) ChangesetPagingResult(sonia.scm.repository.ChangesetPagingResult) LogCommandBuilder(sonia.scm.repository.api.LogCommandBuilder) RepositoryService(sonia.scm.repository.api.RepositoryService)

Example 3 with ChangesetPagingResult

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)));
}
Also used : ChangesetPagingResult(sonia.scm.repository.ChangesetPagingResult) LogCommandBuilder(sonia.scm.repository.api.LogCommandBuilder)

Example 4 with ChangesetPagingResult

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));
}
Also used : ChangesetPagingResult(sonia.scm.repository.ChangesetPagingResult)

Example 5 with ChangesetPagingResult

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");
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) ChangesetPagingResult(sonia.scm.repository.ChangesetPagingResult) Changeset(sonia.scm.repository.Changeset) Person(sonia.scm.repository.Person) Test(org.junit.jupiter.api.Test)

Aggregations

ChangesetPagingResult (sonia.scm.repository.ChangesetPagingResult)10 Changeset (sonia.scm.repository.Changeset)7 Test (org.junit.jupiter.api.Test)6 Person (sonia.scm.repository.Person)6 MergeCommitDto (com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto)4 LogCommandBuilder (sonia.scm.repository.api.LogCommandBuilder)3 CommitDefaults (com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults)2 DisplayUser (sonia.scm.user.DisplayUser)2 User (sonia.scm.user.User)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Repository (sonia.scm.repository.Repository)1 RepositoryService (sonia.scm.repository.api.RepositoryService)1