Search in sources :

Example 31 with NamespaceAndName

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

the class MergeServiceTest method shouldNotEmergencyMergeWithoutPermission.

@Test
void shouldNotEmergencyMergeWithoutPermission() {
    doThrow(UnauthorizedException.class).when(subject).checkPermission("repository:performEmergencyMerge:" + REPOSITORY.getId());
    mockPullRequest("squash", "master", "1");
    MergeCommitDto mergeCommit = createMergeCommit(false);
    NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
    assertThrows(UnauthorizedException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, true));
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) NamespaceAndName(sonia.scm.repository.NamespaceAndName) Test(org.junit.jupiter.api.Test)

Example 32 with NamespaceAndName

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

the class MergeServiceTest method shouldThrowExceptionWhenPullRequestIsNotOpen.

@Test
void shouldThrowExceptionWhenPullRequestIsNotOpen() {
    lenient().when(mergeCommandBuilder.isSupported(MergeStrategy.SQUASH)).thenReturn(true);
    mockPullRequest("squash", "master", "1", REJECTED);
    MergeCommitDto mergeCommit = createMergeCommit(false);
    NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
    assertThrows(CannotMergeNotOpenPullRequestException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, false));
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) NamespaceAndName(sonia.scm.repository.NamespaceAndName) Test(org.junit.jupiter.api.Test)

Example 33 with NamespaceAndName

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

the class MergeServiceTest method shouldThrowExceptionIfObstacleExists.

@Test
void shouldThrowExceptionIfObstacleExists() {
    PullRequest pullRequest = mockPullRequest("squash", "master", "1");
    mockMergeGuard(pullRequest, false);
    MergeCommitDto mergeCommit = createMergeCommit(false);
    NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
    assertThrows(MergeNotAllowedException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, false));
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) NamespaceAndName(sonia.scm.repository.NamespaceAndName) Test(org.junit.jupiter.api.Test)

Example 34 with NamespaceAndName

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

the class MergeServiceTest method shouldNotMergeWithoutPermission.

@Test
void shouldNotMergeWithoutPermission() {
    doThrow(UnauthorizedException.class).when(subject).checkPermission("repository:mergePullRequest:" + REPOSITORY.getId());
    mockPullRequest("squash", "master", "1");
    MergeCommitDto mergeCommit = createMergeCommit(false);
    NamespaceAndName namespaceAndName = REPOSITORY.getNamespaceAndName();
    assertThrows(UnauthorizedException.class, () -> service.merge(namespaceAndName, "1", mergeCommit, MergeStrategy.SQUASH, false));
}
Also used : MergeCommitDto(com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto) NamespaceAndName(sonia.scm.repository.NamespaceAndName) Test(org.junit.jupiter.api.Test)

Example 35 with NamespaceAndName

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

the class RepositoryEngineConfigResourceTest method initRepositoryManager.

@BeforeEach
void initRepositoryManager() {
    lenient().doReturn(REPOSITORY).when(repositoryManager).get(new NamespaceAndName("space", "X"));
    lenient().doReturn(null).when(repositoryManager).get(new NamespaceAndName("unknown", "repository"));
}
Also used : NamespaceAndName(sonia.scm.repository.NamespaceAndName) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

NamespaceAndName (sonia.scm.repository.NamespaceAndName)35 Repository (sonia.scm.repository.Repository)15 PullRequest (com.cloudogu.scm.review.pullrequest.service.PullRequest)11 Operation (io.swagger.v3.oas.annotations.Operation)10 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)10 Path (javax.ws.rs.Path)10 MockHttpRequest (org.jboss.resteasy.mock.MockHttpRequest)8 Test (org.junit.jupiter.api.Test)8 Produces (javax.ws.rs.Produces)7 MergeCommitDto (com.cloudogu.scm.review.pullrequest.dto.MergeCommitDto)6 SubjectAware (com.github.sdorra.shiro.SubjectAware)6 GET (javax.ws.rs.GET)6 Comment (com.cloudogu.scm.review.comment.service.Comment)5 Consumes (javax.ws.rs.Consumes)5 Test (org.junit.Test)5 TestData.createPullRequest (com.cloudogu.scm.review.TestData.createPullRequest)4 BranchRevisionResolver (com.cloudogu.scm.review.pullrequest.dto.BranchRevisionResolver)3 POST (javax.ws.rs.POST)3 NotFoundException (sonia.scm.NotFoundException)3 PermissionCheck (com.cloudogu.scm.review.PermissionCheck)2