use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldEnrichCommitMessageWithCoAuthorsOfSquashedCommits.
@Test
void shouldEnrichCommitMessageWithCoAuthorsOfSquashedCommits() throws IOException {
mockUser("zaphod", "Zaphod Beeblebrox", "zaphod@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("Zaphod Beetlebrox");
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: Arthur Dent <dent@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 shouldNotEmergencyMergeWithoutPermission.
@Test
void shouldNotEmergencyMergeWithoutPermission() {
doThrow(UnauthorizedException.class).when(subject).checkPermission("repository:performEmergencyMerge:" + REPOSITORY.getId());
mockPullRequest("squash", "master", "1");
MergeCommitDto mergeCommit = createMergeCommit(false);
NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
assertThrows(UnauthorizedException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, true));
}
use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldMergeSuccessfully.
@Test
void shouldMergeSuccessfully() {
when(mergeCommandBuilder.isSupported(MergeStrategy.MERGE_COMMIT)).thenReturn(true);
when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
mockPullRequest("squash", "master", "1");
MergeCommitDto mergeCommit = createMergeCommit(false);
service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.MERGE_COMMIT, false);
verify(pullRequestService).setRevisions(REPOSITORY, "1", "1", "2");
verify(pullRequestService, never()).setEmergencyMerged(any(Repository.class), anyString(), anyString(), anyList());
}
use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldThrowExceptionWhenPullRequestIsNotOpen.
@Test
void shouldThrowExceptionWhenPullRequestIsNotOpen() {
lenient().when(mergeCommandBuilder.isSupported(MergeStrategy.SQUASH)).thenReturn(true);
mockPullRequest("squash", "master", "1", REJECTED);
MergeCommitDto mergeCommit = createMergeCommit(false);
NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
assertThrows(CannotMergeNotOpenPullRequestException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, false));
}
use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldThrowExceptionIfObstacleExists.
@Test
void shouldThrowExceptionIfObstacleExists() {
PullRequest pullRequest = mockPullRequest("squash", "master", "1");
mockMergeGuard(pullRequest, false);
MergeCommitDto mergeCommit = createMergeCommit(false);
NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
assertThrows(MergeNotAllowedException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, false));
}
Aggregations