use of com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults in project scm-review-plugin by scm-manager.
the class MergeResourceTest method shouldGetRebaseMergeStrategyInfo.
@Test
void shouldGetRebaseMergeStrategyInfo() throws URISyntaxException, UnsupportedEncodingException {
CommitDefaults commitDefaults = new CommitDefaults("happy days", DisplayUser.from(new User("Arthur Dent")));
when(mergeService.createCommitDefaults(any(), any(), eq(REBASE))).thenReturn(commitDefaults);
when(mergeService.isCommitMessageDisabled(REBASE)).thenReturn(true);
when(mergeService.createMergeCommitMessageHint(REBASE)).thenReturn(null);
MockHttpRequest request = createHttpGetRequest(MERGE_URL + "/merge-strategy-info/?strategy=REBASE");
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("happy days").contains("true").doesNotContain("commitMessageHint");
}
use of com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults in project scm-review-plugin by scm-manager.
the class MergeResourceTest method shouldGetSquashMergeStrategyInfoWithoutMail.
@Test
void shouldGetSquashMergeStrategyInfoWithoutMail() throws URISyntaxException {
when(mergeService.createCommitDefaults(any(), any(), eq(SQUASH))).thenReturn(new CommitDefaults("happy days", DisplayUser.from(new User("Arthur Dent"))));
when(mergeService.isCommitMessageDisabled(SQUASH)).thenReturn(true);
when(mergeService.createMergeCommitMessageHint(SQUASH)).thenReturn(null);
MockHttpRequest request = createHttpGetRequest(MERGE_URL + "/merge-strategy-info/?strategy=SQUASH");
JsonMockHttpResponse response = new JsonMockHttpResponse();
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
JsonNode jsonResponse = response.getContentAsJson();
assertThat(jsonResponse.get("commitMessageDisabled").asBoolean()).isTrue();
assertThat(jsonResponse.get("defaultCommitMessage").asText()).isEqualTo("happy days");
assertThat(jsonResponse.get("commitAuthor").asText()).isEqualTo("Arthur Dent");
assertThat(jsonResponse.get("commitMessageHint")).isNull();
}
use of com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults in project scm-review-plugin by scm-manager.
the class MergeResourceTest method shouldGetSquashMergeStrategyInfoWithMail.
@Test
void shouldGetSquashMergeStrategyInfoWithMail() throws URISyntaxException {
when(mergeService.createCommitDefaults(any(), any(), eq(SQUASH))).thenReturn(new CommitDefaults("happy days", DisplayUser.from(new User("dent", "Arthur Dent", "arthur@hitchhiker.com"))));
MockHttpRequest request = createHttpGetRequest(MERGE_URL + "/merge-strategy-info/?strategy=SQUASH");
JsonMockHttpResponse response = new JsonMockHttpResponse();
dispatcher.invoke(request, response);
JsonNode jsonResponse = response.getContentAsJson();
assertThat(jsonResponse.get("commitAuthor").asText()).isEqualTo("Arthur Dent <arthur@hitchhiker.com>");
}
use of com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldOmitAuthorForNonSquash.
@Test
void shouldOmitAuthorForNonSquash() {
PullRequest pullRequest = createPullRequest();
when(pullRequestService.get(REPOSITORY.getNamespace(), REPOSITORY.getName(), "1")).thenReturn(pullRequest);
CommitDefaults commitDefaults = service.createCommitDefaults(REPOSITORY.getNamespaceAndName(), "1", MergeStrategy.MERGE_COMMIT);
assertThat(commitDefaults.getCommitAuthor()).isNull();
}
use of com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults in project scm-review-plugin by scm-manager.
the class MergeResourceTest method shouldNotSetCommitAuthorForNonSquash.
@Test
void shouldNotSetCommitAuthorForNonSquash() throws URISyntaxException {
when(mergeService.createCommitDefaults(any(), any(), eq(MERGE_COMMIT))).thenReturn(new CommitDefaults("happy days", null));
MockHttpRequest request = createHttpGetRequest(MERGE_URL + "/merge-strategy-info/?strategy=MERGE_COMMIT");
JsonMockHttpResponse response = new JsonMockHttpResponse();
dispatcher.invoke(request, response);
JsonNode jsonResponse = response.getContentAsJson();
assertThat(jsonResponse.get("commitAuthor")).isNull();
}
Aggregations