Search in sources :

Example 1 with DeleteBranchesInput

use of com.google.gerrit.extensions.api.projects.DeleteBranchesInput in project gerrit by GerritCodeReview.

the class DeleteBranchesIT method deleteBranchesForbidden.

@Test
public void deleteBranchesForbidden() throws Exception {
    DeleteBranchesInput input = new DeleteBranchesInput();
    input.branches = BRANCHES;
    setApiUser(user);
    try {
        project().deleteBranches(input);
        fail("Expected ResourceConflictException");
    } catch (ResourceConflictException e) {
        assertThat(e).hasMessageThat().isEqualTo(errorMessageForBranches(BRANCHES));
    }
    setApiUser(admin);
    assertBranches(BRANCHES);
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) DeleteBranchesInput(com.google.gerrit.extensions.api.projects.DeleteBranchesInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with DeleteBranchesInput

use of com.google.gerrit.extensions.api.projects.DeleteBranchesInput in project gerrit by GerritCodeReview.

the class DeleteBranchesIT method deleteBranchesNotFound.

@Test
public void deleteBranchesNotFound() throws Exception {
    DeleteBranchesInput input = new DeleteBranchesInput();
    List<String> branches = Lists.newArrayList(BRANCHES);
    branches.add("refs/heads/does-not-exist");
    input.branches = branches;
    try {
        project().deleteBranches(input);
        fail("Expected ResourceConflictException");
    } catch (ResourceConflictException e) {
        assertThat(e).hasMessageThat().isEqualTo(errorMessageForBranches(ImmutableList.of("refs/heads/does-not-exist")));
    }
    assertBranchesDeleted();
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) DeleteBranchesInput(com.google.gerrit.extensions.api.projects.DeleteBranchesInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with DeleteBranchesInput

use of com.google.gerrit.extensions.api.projects.DeleteBranchesInput in project gerrit by GerritCodeReview.

the class DeleteBranchesIT method emptyBranchList.

@Test
public void emptyBranchList() throws Exception {
    DeleteBranchesInput input = new DeleteBranchesInput();
    input.branches = Lists.newArrayList();
    exception.expect(BadRequestException.class);
    exception.expectMessage("branches must be specified");
    project().deleteBranches(input);
}
Also used : DeleteBranchesInput(com.google.gerrit.extensions.api.projects.DeleteBranchesInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with DeleteBranchesInput

use of com.google.gerrit.extensions.api.projects.DeleteBranchesInput in project gerrit by GerritCodeReview.

the class DeleteBranchesIT method deleteBranchesNotFoundContinue.

@Test
public void deleteBranchesNotFoundContinue() throws Exception {
    // If it fails on the first branch in the input, it should still
    // continue to process the remaining branches.
    DeleteBranchesInput input = new DeleteBranchesInput();
    List<String> branches = Lists.newArrayList("refs/heads/does-not-exist");
    branches.addAll(BRANCHES);
    input.branches = branches;
    try {
        project().deleteBranches(input);
        fail("Expected ResourceConflictException");
    } catch (ResourceConflictException e) {
        assertThat(e).hasMessageThat().isEqualTo(errorMessageForBranches(ImmutableList.of("refs/heads/does-not-exist")));
    }
    assertBranchesDeleted();
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) DeleteBranchesInput(com.google.gerrit.extensions.api.projects.DeleteBranchesInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with DeleteBranchesInput

use of com.google.gerrit.extensions.api.projects.DeleteBranchesInput in project gerrit by GerritCodeReview.

the class DeleteBranchesIT method missingBranchList.

@Test
public void missingBranchList() throws Exception {
    DeleteBranchesInput input = new DeleteBranchesInput();
    exception.expect(BadRequestException.class);
    exception.expectMessage("branches must be specified");
    project().deleteBranches(input);
}
Also used : DeleteBranchesInput(com.google.gerrit.extensions.api.projects.DeleteBranchesInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 DeleteBranchesInput (com.google.gerrit.extensions.api.projects.DeleteBranchesInput)7 Test (org.junit.Test)7 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1