use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method initRepoWithPRs.
private void initRepoWithPRs(String namespace, String name) throws IOException {
mockChangesets("develop", "master", new Changeset());
when(repository.getNamespace()).thenReturn(namespace);
when(repository.getName()).thenReturn(name);
PullRequest openedPR1 = createPullRequest("opened_1", PullRequestStatus.OPEN);
PullRequest openedPR2 = createPullRequest("opened_2", PullRequestStatus.OPEN);
PullRequest mergedPR1 = createPullRequest("merged_1", PullRequestStatus.MERGED);
PullRequest mergedPR2 = createPullRequest("merged_2", PullRequestStatus.MERGED);
PullRequest rejectedPR1 = createPullRequest("rejected_1", REJECTED);
PullRequest rejectedPR2 = createPullRequest("rejected_2", REJECTED);
openedPR2.setAuthor("author");
mergedPR2.setAuthor("author");
openedPR1.setReviewer(singletonMap("reviewer", false));
mergedPR1.setReviewer(singletonMap("reviewer", true));
when(store.getAll()).thenReturn(Lists.newArrayList(openedPR1, openedPR2, rejectedPR1, rejectedPR2, mergedPR1, mergedPR2));
when(commentService.getAll(any(), any(), any())).thenReturn(Collections.emptyList());
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnPullRequestIsValidResult.
@Test
@SubjectAware(username = "dent")
public void shouldReturnPullRequestIsValidResult() 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=feature&target=master");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("\"status\":\"PR_VALID\"");
assertThat(response.getContentAsString()).contains("\"_links\":{\"self\":{\"href\":\"/v2/pull-requests/ns/repo/check?source=feature&target=master\"}}");
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldNotEnrichCommitMessageWithMergerAsCoAuthor.
@Test
void shouldNotEnrichCommitMessageWithMergerAsCoAuthor() throws IOException {
mockUser("arthur", "Arthur Dent", "dent@hitchhiker.org");
when(mergeCommandBuilder.isSupported(MergeStrategy.SQUASH)).thenReturn(true);
when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
ImmutableList<Changeset> changesets = ImmutableList.of(new Changeset("1", 1L, new Person("Arthur Dent", "dent@hitchhiker.org"), "42\n\nCo-authored-by: Tricia McMillan <trillian@hitchhiker.org>"), new Changeset("2", 2L, new Person("Arthur Dent", "dent@hitchhiker.org"), "42\n\nCo-authored-by: Arthur Dent <dent@hitchhiker.org>"));
when(logCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(1, changesets));
PullRequest pullRequest = mockPullRequest("squash", "master", "1");
pullRequest.setAuthor("Arthur Dent");
MergeCommitDto mergeCommit = createMergeCommit(false);
mergeCommit.setCommitMessage("42");
service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.SQUASH, false);
verify(mergeCommandBuilder).setMessage("42\n\n" + "Co-authored-by: Tricia McMillan <trillian@hitchhiker.org>\n");
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldEnrichCommitMessageWithCoAuthoredBy.
@Test
void shouldEnrichCommitMessageWithCoAuthoredBy() throws IOException {
mockUser("zaphod", "Zaphod Beeblebrox", "zaphod@hitchhiker.org");
when(mergeCommandBuilder.isSupported(MergeStrategy.SQUASH)).thenReturn(true);
when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
ImmutableList<Changeset> changesets = ImmutableList.of(new Changeset("1", 1L, new Person("Arthur Dent", "dent@hitchhiker.org")), new Changeset("2", 2L, new Person("Tricia McMillan", "trillian@hitchhiker.org")));
when(logCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(1, changesets));
mockPullRequest("squash", "master", "1");
MergeCommitDto mergeCommit = createMergeCommit(false);
mergeCommit.setCommitMessage("42");
service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.SQUASH, false);
verify(mergeCommandBuilder).setMessage("42\n\n" + "Co-authored-by: Arthur Dent <dent@hitchhiker.org>\n" + "Co-authored-by: Tricia McMillan <trillian@hitchhiker.org>\n");
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class ModificationCollectorTest method shouldCloseRepositorySerice.
@Test
void shouldCloseRepositorySerice() throws IOException {
Changeset one = changeset("21").added("a.txt").removed("b.txt").build();
collector.collect(repository, ImmutableList.of(one));
verify(repositoryService).close();
}
Aggregations