use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldDeleteBranchIfFlagIsSet.
@Test
void shouldDeleteBranchIfFlagIsSet() {
when(mergeCommandBuilder.isSupported(MergeStrategy.MERGE_COMMIT)).thenReturn(true);
when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
mockPullRequest("squash", "master", "1");
when(repositoryService.getBranchCommand()).thenReturn(branchCommandBuilder);
when(repositoryService.isSupported(Command.BRANCH)).thenReturn(true);
MergeCommitDto mergeCommit = createMergeCommit(true);
service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.MERGE_COMMIT, false);
verify(branchCommandBuilder).delete("squash");
}
use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldUpdatePullRequestStatus.
@Test
void shouldUpdatePullRequestStatus() throws IOException {
mocksForPullRequestUpdate("master");
mockPullRequest("squash", "master", "1");
MergeCommitDto mergeCommit = createMergeCommit(true);
service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.MERGE_COMMIT, false);
verify(pullRequestService).setMerged(REPOSITORY, "1");
}
use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldClosePullRequestsWithDeletedBranchesOnMerge.
@Test
void shouldClosePullRequestsWithDeletedBranchesOnMerge() {
PullRequest pullRequest = mockPullRequest("commit", "master", "1");
PullRequest pullRequest2 = mockPullRequest("master", "commit", "2");
when(mergeCommandBuilder.isSupported(MergeStrategy.MERGE_COMMIT)).thenReturn(true);
when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
when(repositoryService.isSupported(Command.BRANCH)).thenReturn(true);
BranchCommandBuilder branchCommand = mock(BranchCommandBuilder.class);
when(repositoryService.getBranchCommand()).thenReturn(branchCommand);
when(pullRequestService.getAll(REPOSITORY.getNamespace(), REPOSITORY.getName())).thenReturn(ImmutableList.of(pullRequest, pullRequest2));
MergeCommitDto mergeCommit = createMergeCommit(true);
service.merge(REPOSITORY.getNamespaceAndName(), pullRequest.getId(), mergeCommit, MergeStrategy.MERGE_COMMIT, false);
verify(branchCommand).delete(pullRequest.getSource());
verify(pullRequestService, times(1)).setRejected(REPOSITORY, "2", PullRequestRejectedEvent.RejectionCause.BRANCH_DELETED);
verify(pullRequestService, never()).setRejected(REPOSITORY, "1", PullRequestRejectedEvent.RejectionCause.BRANCH_DELETED);
}
use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldNotEnrichCommitMessageWithMergerAsReviewer.
@Test
void shouldNotEnrichCommitMessageWithMergerAsReviewer() 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("Zaphod Beeblebrox", "zaphod@hitchhiker.org"), "42\n\nCo-authored-by: Tricia McMillan <trillian@hitchhiker.org>"), new Changeset("2", 2L, new Person("Tricia McMillan", "trillian@hitchhiker.org"), "42\n\n"));
when(logCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(1, changesets));
PullRequest pullRequest = mockPullRequest("squash", "master", "1");
pullRequest.setAuthor("Arthur Dent");
HashMap<String, Boolean> reviewers = new HashMap<>();
reviewers.put("dent", true);
pullRequest.setReviewer(reviewers);
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: Zaphod Beeblebrox <zaphod@hitchhiker.org>\n" + "Co-authored-by: Tricia McMillan <trillian@hitchhiker.org>\n");
}
use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldNotThrowExceptionIfObstacleIsOverrideable.
@Test
void shouldNotThrowExceptionIfObstacleIsOverrideable() throws IOException {
mocksForPullRequestUpdate("master");
PullRequest pullRequest = mockPullRequest("squash", "master", "1");
mockMergeGuard(pullRequest, true);
MergeCommitDto mergeCommit = createMergeCommit(true);
service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.MERGE_COMMIT, true);
verify(pullRequestService).setEmergencyMerged(any(Repository.class), anyString(), anyString(), anyList());
}
Aggregations