Search in sources :

Example 1 with BatchLabelInput

use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.

the class PostLabelsIT method cannotSetCommitMessageOnLabelDefinitionInputForUpdate.

@Test
public void cannotSetCommitMessageOnLabelDefinitionInputForUpdate() throws Exception {
    LabelDefinitionInput labelInput = new LabelDefinitionInput();
    labelInput.commitMessage = "Update label";
    BatchLabelInput input = new BatchLabelInput();
    input.update = ImmutableMap.of(LabelId.CODE_REVIEW, labelInput);
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(allProjects.get()).labels(input));
    assertThat(thrown).hasMessageThat().contains("commit message on label definition input not supported");
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) BatchLabelInput(com.google.gerrit.extensions.common.BatchLabelInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 2 with BatchLabelInput

use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.

the class PostLabelsIT method cannotDeleteTheSameLabelTwice.

@Test
public void cannotDeleteTheSameLabelTwice() throws Exception {
    configLabel("Foo", LabelFunction.NO_OP);
    BatchLabelInput input = new BatchLabelInput();
    input.delete = ImmutableList.of("Foo", "Foo");
    UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> gApi.projects().name(project.get()).labels(input));
    assertThat(thrown).hasMessageThat().contains("label Foo not found");
}
Also used : UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) BatchLabelInput(com.google.gerrit.extensions.common.BatchLabelInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 3 with BatchLabelInput

use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.

the class PostLabelsIT method deleteLabels.

@Test
public void deleteLabels() throws Exception {
    configLabel("Foo", LabelFunction.NO_OP);
    configLabel("Bar", LabelFunction.NO_OP);
    assertThat(gApi.projects().name(project.get()).labels().get()).isNotEmpty();
    BatchLabelInput input = new BatchLabelInput();
    input.delete = ImmutableList.of("Foo", "Bar");
    gApi.projects().name(project.get()).labels(input);
    assertThat(gApi.projects().name(project.get()).labels().get()).isEmpty();
}
Also used : BatchLabelInput(com.google.gerrit.extensions.common.BatchLabelInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 4 with BatchLabelInput

use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.

the class PostLabelsIT method notAllowed.

@Test
public void notAllowed() throws Exception {
    projectOperations.project(allProjects).forUpdate().add(allow(Permission.READ).ref(RefNames.REFS_CONFIG).group(REGISTERED_USERS)).update();
    requestScopeOperations.setApiUser(user.id());
    AuthException thrown = assertThrows(AuthException.class, () -> gApi.projects().name(allProjects.get()).labels(new BatchLabelInput()));
    assertThat(thrown).hasMessageThat().contains("write refs/meta/config not permitted");
}
Also used : AuthException(com.google.gerrit.extensions.restapi.AuthException) BatchLabelInput(com.google.gerrit.extensions.common.BatchLabelInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 5 with BatchLabelInput

use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.

the class PostLabelsIT method anonymous.

@Test
public void anonymous() throws Exception {
    requestScopeOperations.setApiUserAnonymous();
    AuthException thrown = assertThrows(AuthException.class, () -> gApi.projects().name(allProjects.get()).labels(new BatchLabelInput()));
    assertThat(thrown).hasMessageThat().contains("Authentication required");
}
Also used : AuthException(com.google.gerrit.extensions.restapi.AuthException) BatchLabelInput(com.google.gerrit.extensions.common.BatchLabelInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

BatchLabelInput (com.google.gerrit.extensions.common.BatchLabelInput)27 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)26 Test (org.junit.Test)26 LabelDefinitionInput (com.google.gerrit.extensions.common.LabelDefinitionInput)17 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)5 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)4 LabelDefinitionInfo (com.google.gerrit.extensions.common.LabelDefinitionInfo)3 AuthException (com.google.gerrit.extensions.restapi.AuthException)3 LabelType (com.google.gerrit.entities.LabelType)1 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)1 ProjectConfig (com.google.gerrit.server.project.ProjectConfig)1 Map (java.util.Map)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1