Search in sources :

Example 6 with NotFoundException

use of sonia.scm.NotFoundException in project scm-review-plugin by scm-manager.

the class PullRequestRootResourceTest method shouldHandleMissingBranch.

@Test
@SubjectAware(username = "slarti")
public void shouldHandleMissingBranch() throws URISyntaxException, IOException {
    when(branchResolver.resolve(repository, "sourceBranch")).thenThrow(new NotFoundException("x", "y"));
    byte[] pullRequestJson = loadJson("com/cloudogu/scm/review/pullRequest.json");
    MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/" + REPOSITORY_NAMESPACE + "/" + REPOSITORY_NAME).content(pullRequestJson).contentType(PullRequestMediaType.PULL_REQUEST);
    dispatcher.invoke(request, response);
    assertThat(response.getContentAsString()).containsPattern("could not find.*");
}
Also used : MockHttpRequest(org.jboss.resteasy.mock.MockHttpRequest) NotFoundException(sonia.scm.NotFoundException) Test(org.junit.Test) SubjectAware(com.github.sdorra.shiro.SubjectAware)

Aggregations

NotFoundException (sonia.scm.NotFoundException)6 SubjectAware (com.github.sdorra.shiro.SubjectAware)3 MockHttpRequest (org.jboss.resteasy.mock.MockHttpRequest)3 Test (org.junit.Test)3 NamespaceAndName (sonia.scm.repository.NamespaceAndName)3 Repository (sonia.scm.repository.Repository)2 PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)1 Test (org.junit.jupiter.api.Test)1 ContextEntry (sonia.scm.ContextEntry)1