use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class BranchRevisionResolverTest method shouldGetEmptyRevisionsIfBranchDoesntExist.
@Test
void shouldGetEmptyRevisionsIfBranchDoesntExist() throws IOException {
when(repositoryServiceFactory.create(NAMESPACE_AND_NAME)).thenReturn(repositoryService);
setUpBranches("featureBranch");
PullRequest pullRequest = TestData.createPullRequest();
pullRequest.setSource("notExisting");
pullRequest.setTarget("featureBranch");
mockSingleChangeset(pullRequest.getSource());
mockSingleChangeset(pullRequest.getTarget());
BranchRevisionResolver.RevisionResult revisions = branchRevisionResolver.getRevisions(NAMESPACE_AND_NAME, pullRequest);
// verify that get branches is called only once, because it is expensive
verify(branchesCommandBuilder).getBranches();
Assertions.assertThat(revisions.getSourceRevision()).isEqualTo("");
Assertions.assertThat(revisions.getTargetRevision()).isEqualTo("featureBranchId");
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class MyOpenReviewsTest method createPullRequest.
private static PullRequest createPullRequest(String id, PullRequestStatus status, String reviewer, boolean reviewStatus) {
PullRequest existingPullRequest = new PullRequest();
existingPullRequest.setId(id);
existingPullRequest.setTitle("title " + id);
existingPullRequest.setSource("source");
existingPullRequest.setTarget("target");
existingPullRequest.setStatus(status);
existingPullRequest.setAuthor("dent");
existingPullRequest.setReviewer(ImmutableMap.of("someone", false, reviewer, reviewStatus));
return existingPullRequest;
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class MyPullRequestsTest method createPullRequest.
private static PullRequest createPullRequest(String id, PullRequestStatus status, String author) {
PullRequest existingPullRequest = new PullRequest();
existingPullRequest.setId(id);
existingPullRequest.setTitle("title " + id);
existingPullRequest.setSource("source");
existingPullRequest.setTarget("target");
existingPullRequest.setStatus(status);
existingPullRequest.setAuthor(author);
return existingPullRequest;
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnAlreadyExistsResult.
@Test
@SubjectAware(username = "dent")
public void shouldReturnAlreadyExistsResult() throws URISyntaxException, IOException {
mockLoggedInUser(new User("dent"));
mockLogCommandForPullRequestCheck(ImmutableList.of(new Changeset()));
PullRequest pullRequest = createPullRequest();
when(store.getAll()).thenReturn(ImmutableList.of(pullRequest));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/check?source=develop&target=master");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("\"status\":\"PR_ALREADY_EXISTS\"");
assertThat(response.getContentAsString()).contains("\"_links\":{\"self\":{\"href\":\"/v2/pull-requests/ns/repo/check?source=develop&target=master\"}}");
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetTheSubscriptionLink.
@Test
public void shouldGetTheSubscriptionLink() throws URISyntaxException, IOException {
// the PR has no subscriber
PullRequest pullRequest = createPullRequest();
when(store.get("1")).thenReturn(pullRequest);
mockLoggedInUser(new User("user1", "User 1", "email@d.de"));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/1/subscription");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readValue(response.getContentAsString(), JsonNode.class);
assertThat(jsonNode.path("_links").get("subscribe")).isNotNull();
assertThat(jsonNode.path("_links").get("unsubscribe")).isNull();
}
Aggregations