Search in sources :

Example 16 with MergeCommitDto

use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.

the class MergeServiceTest method shouldEmergencyMergeSuccessfully.

@Test
void shouldEmergencyMergeSuccessfully() {
    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, true);
    verify(pullRequestService).setEmergencyMerged(REPOSITORY, "1", mergeCommit.getOverrideMessage(), Collections.emptyList());
    verify(pullRequestService, never()).setMerged(REPOSITORY, "1");
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) Test(org.junit.jupiter.api.Test)

Example 17 with MergeCommitDto

use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.

the class MergeServiceTest method shouldNotMergeWithoutPermission.

@Test
void shouldNotMergeWithoutPermission() {
    doThrow(UnauthorizedException.class).when(subject).checkPermission("repository:mergePullRequest:" + REPOSITORY.getId());
    mockPullRequest("squash", "master", "1");
    MergeCommitDto mergeCommit = createMergeCommit(false);
    NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
    assertThrows(UnauthorizedException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, false));
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) NamespaceAndName(sonia.scm.repository.NamespaceAndName) Test(org.junit.jupiter.api.Test)

Example 18 with MergeCommitDto

use of com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto in project scm-review-plugin by scm-manager.

the class MergeServiceTest method shouldEnrichCommitMessageWithReviewedBy.

@Test
void shouldEnrichCommitMessageWithReviewedBy() {
    mockUser("zaphod", "Zaphod Beeblebrox", "zaphod@hitchhiker.org");
    when(mergeCommandBuilder.isSupported(MergeStrategy.MERGE_COMMIT)).thenReturn(true);
    when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
    when(userDisplayManager.get("trillian")).thenReturn(of(DisplayUser.from(new User("trillian", "Tricia McMillan", "trillian@hitchhiker.org"))));
    when(userDisplayManager.get("dent")).thenReturn(of(DisplayUser.from(new User("dent", "Arthur Dent", "dent@hitchhiker.org"))));
    PullRequest pullRequest = mockPullRequest("squash", "master", "1");
    LinkedHashMap<String, Boolean> reviewers = new LinkedHashMap<>();
    reviewers.put("dent", true);
    reviewers.put("trillian", true);
    reviewers.put("zaphod", false);
    pullRequest.setReviewer(reviewers);
    MergeCommitDto mergeCommit = createMergeCommit(false);
    mergeCommit.setCommitMessage("42");
    service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.MERGE_COMMIT, false);
    verify(mergeCommandBuilder).setMessage("42\n\n" + "Reviewed-by: Arthur Dent <dent@hitchhiker.org>\n" + "Reviewed-by: Tricia McMillan <trillian@hitchhiker.org>\n");
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) DisplayUser(sonia.scm.user.DisplayUser) User(sonia.scm.user.User) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Aggregations

MergeCommitDto (com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto)18 Test (org.junit.jupiter.api.Test)17 NamespaceAndName (sonia.scm.repository.NamespaceAndName)6 Changeset (sonia.scm.repository.Changeset)4 ChangesetPagingResult (sonia.scm.repository.ChangesetPagingResult)4 Person (sonia.scm.repository.Person)4 LinkedHashMap (java.util.LinkedHashMap)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Repository (sonia.scm.repository.Repository)2 HashMap (java.util.HashMap)1 BranchCommandBuilder (sonia.scm.repository.api.BranchCommandBuilder)1 DisplayUser (sonia.scm.user.DisplayUser)1 User (sonia.scm.user.User)1