use of sonia.scm.web.JsonMockHttpResponse 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 sonia.scm.web.JsonMockHttpResponse 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 sonia.scm.web.JsonMockHttpResponse 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