Search in sources :

Example 61 with Repository

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

the class MergeServiceTest method shouldMergeSuccessfully.

@Test
void shouldMergeSuccessfully() {
    when(mergeCommandBuilder.isSupported(MergeStrategy.MERGE_COMMIT)).thenReturn(true);
    when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
    mockPullRequest("squash", "master", "1");
    MergeCommitDto mergeCommit = createMergeCommit(false);
    service.merge(REPOSITORY.getNamespaceAndName(), "1", mergeCommit, MergeStrategy.MERGE_COMMIT, false);
    verify(pullRequestService).setRevisions(REPOSITORY, "1", "1", "2");
    verify(pullRequestService, never()).setEmergencyMerged(any(Repository.class), anyString(), anyString(), anyList());
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) Repository(sonia.scm.repository.Repository) Test(org.junit.jupiter.api.Test)

Example 62 with Repository

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

the class PullRequestCollectorTest method shouldReturnPullRequestWithAffectedSourceBranch.

@Test
void shouldReturnPullRequestWithAffectedSourceBranch() {
    PullRequest pullRequest = TestData.createPullRequest("42", PullRequestStatus.OPEN);
    List<PullRequest> requests = ImmutableList.of(pullRequest);
    Repository repository = RepositoryTestData.createHeartOfGold("git");
    when(pullRequestService.getAll(repository.getNamespace(), repository.getName())).thenReturn(requests);
    List<PullRequest> prs = collector.collectAffectedPullRequests(repository, ImmutableList.of("develop"));
    assertThat(prs).containsOnly(pullRequest);
}
Also used : Repository(sonia.scm.repository.Repository) Test(org.junit.jupiter.api.Test)

Example 63 with Repository

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

the class PullRequestCollectorTest method shouldReturnOnlyOpenPullRequest.

@Test
void shouldReturnOnlyOpenPullRequest() {
    PullRequest one = TestData.createPullRequest("21", PullRequestStatus.OPEN);
    PullRequest two = TestData.createPullRequest("42", PullRequestStatus.REJECTED);
    PullRequest three = TestData.createPullRequest("64", PullRequestStatus.MERGED);
    List<PullRequest> requests = ImmutableList.of(one, two, three);
    Repository repository = RepositoryTestData.createHeartOfGold("git");
    when(pullRequestService.getAll(repository.getNamespace(), repository.getName())).thenReturn(requests);
    List<PullRequest> prs = collector.collectAffectedPullRequests(repository, ImmutableList.of("master", "develop"));
    assertThat(prs).containsOnly(one);
}
Also used : Repository(sonia.scm.repository.Repository) Test(org.junit.jupiter.api.Test)

Example 64 with Repository

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

the class PullRequestCollectorTest method shouldReturnPullRequestWithAffectedTargetBranch.

@Test
void shouldReturnPullRequestWithAffectedTargetBranch() {
    PullRequest pullRequest = TestData.createPullRequest("42", PullRequestStatus.OPEN);
    List<PullRequest> requests = ImmutableList.of(pullRequest);
    Repository repository = RepositoryTestData.createHeartOfGold("git");
    when(pullRequestService.getAll(repository.getNamespace(), repository.getName())).thenReturn(requests);
    List<PullRequest> prs = collector.collectAffectedPullRequests(repository, ImmutableList.of("master"));
    assertThat(prs).containsOnly(pullRequest);
}
Also used : Repository(sonia.scm.repository.Repository) Test(org.junit.jupiter.api.Test)

Example 65 with Repository

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

the class PullRequestStoreFactoryTest method shouldCreateCommentStore.

@Test
public void shouldCreateCommentStore() {
    Repository repository = RepositoryTestData.createHeartOfGold("git");
    repository.setId("repo");
    when(dataStoreFactory.getStore(any())).thenReturn((DataStore) store);
    when(dataStoreFactory.withType(any())).thenCallRealMethod();
    PullRequestStore commentStore = storeFactory.create(repository);
    assertThat(commentStore).isNotNull();
}
Also used : Repository(sonia.scm.repository.Repository) Test(org.junit.jupiter.api.Test)

Aggregations

Repository (sonia.scm.repository.Repository)66 PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)25 Operation (io.swagger.v3.oas.annotations.Operation)20 Path (javax.ws.rs.Path)20 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)19 NamespaceAndName (sonia.scm.repository.NamespaceAndName)16 GET (javax.ws.rs.GET)11 Produces (javax.ws.rs.Produces)11 Test (org.junit.jupiter.api.Test)9 Subscribe (com.github.legman.Subscribe)6 SubjectAware (com.github.sdorra.shiro.SubjectAware)6 Consumes (javax.ws.rs.Consumes)6 POST (javax.ws.rs.POST)6 Test (org.junit.Test)6 HalEnricherContext (sonia.scm.api.v2.resources.HalEnricherContext)6 PermissionCheck (com.cloudogu.scm.review.PermissionCheck)5 PullRequestResourceLinks (com.cloudogu.scm.review.PullRequestResourceLinks)5 Comment (com.cloudogu.scm.review.comment.service.Comment)5 PullRequestService (com.cloudogu.scm.review.pullrequest.service.PullRequestService)5 Inject (javax.inject.Inject)5