use of org.jboss.resteasy.mock.MockHttpRequest 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 org.jboss.resteasy.mock.MockHttpRequest 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 org.jboss.resteasy.mock.MockHttpRequest in project scm-review-plugin by scm-manager.
the class MergeResourceTest method shouldHandleFailedDryRun.
@Test
void shouldHandleFailedDryRun() throws IOException, URISyntaxException {
when(mergeService.checkMerge(any(), any())).thenReturn(new MergeCheckResult(true, emptyList()));
byte[] mergeCommandJson = loadJson("com/cloudogu/scm/review/mergeCommand.json");
MockHttpRequest request = createHttpPostRequest(MERGE_URL + "/merge-check", mergeCommandJson);
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("\"hasConflicts\":true");
}
use of org.jboss.resteasy.mock.MockHttpRequest in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetAllPR.
@Test
@SubjectAware(username = "trillian")
public void shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetAllPR() throws URISyntaxException {
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/" + REPOSITORY_NAMESPACE + "/" + REPOSITORY_NAME + "");
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
}
use of org.jboss.resteasy.mock.MockHttpRequest in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetPR.
@Test
@SubjectAware(username = "trillian")
public void shouldGetUnauthorizedExceptionWhenMissingPermissionOnGetPR() throws URISyntaxException {
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/" + REPOSITORY_NAMESPACE + "/" + REPOSITORY_NAME + "/123");
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
}
Aggregations