use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class ModificationCollectorTest method shouldCloseRepositoryServiceEvenOnError.
@Test
void shouldCloseRepositoryServiceEvenOnError() throws IOException {
when(repositoryService.getModificationsCommand()).thenThrow(new IllegalStateException("fail"));
Changeset one = changeset("21").added("a.txt").removed("b.txt").build();
try {
collector.collect(repository, ImmutableList.of(one));
} catch (IllegalStateException ex) {
// we only want to verify, if the repository service was closed
}
verify(repositoryService).close();
}
use of sonia.scm.repository.Changeset 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 sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnBranchesNotDifferResultIfSameBranches.
@Test
@SubjectAware(username = "dent")
public void shouldReturnBranchesNotDifferResultIfSameBranches() throws URISyntaxException, IOException {
mockLoggedInUser(new User("dent"));
mockLogCommandForPullRequestCheck(ImmutableList.of(new Changeset()));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/check?source=master&target=master");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("\"status\":\"BRANCHES_NOT_DIFFER\"");
assertThat(response.getContentAsString()).contains("\"_links\":{\"self\":{\"href\":\"/v2/pull-requests/ns/repo/check?source=master&target=master\"}}");
}
use of sonia.scm.repository.Changeset in project scm-review-plugin by scm-manager.
the class MergeServiceTest method shouldNotEnrichCommitMessageWithMergerAsReviewer.
@Test
void shouldNotEnrichCommitMessageWithMergerAsReviewer() 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("Zaphod Beeblebrox", "zaphod@hitchhiker.org"), "42\n\nCo-authored-by: Tricia McMillan <trillian@hitchhiker.org>"), new Changeset("2", 2L, new Person("Tricia McMillan", "trillian@hitchhiker.org"), "42\n\n"));
when(logCommandBuilder.getChangesets()).thenReturn(new ChangesetPagingResult(1, changesets));
PullRequest pullRequest = mockPullRequest("squash", "master", "1");
pullRequest.setAuthor("Arthur Dent");
HashMap<String, Boolean> reviewers = new HashMap<>();
reviewers.put("dent", true);
pullRequest.setReviewer(reviewers);
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: Zaphod Beeblebrox <zaphod@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 MergeServiceTest method shouldEnrichCommitMessageWithCoAuthorsOfSquashedCommits.
@Test
void shouldEnrichCommitMessageWithCoAuthorsOfSquashedCommits() 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"), "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("Zaphod Beetlebrox");
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");
}
Aggregations