Search in sources :

Example 26 with BatchLabelInput

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

the class PostLabelsIT method cannotDeleteAndUpdateLabel.

@Test
public void cannotDeleteAndUpdateLabel() throws Exception {
    configLabel("Foo", LabelFunction.NO_OP);
    LabelDefinitionInput fooInput = new LabelDefinitionInput();
    fooInput.function = LabelFunction.MAX_NO_BLOCK.getFunctionName();
    BatchLabelInput input = new BatchLabelInput();
    input.delete = ImmutableList.of("Foo");
    input.update = ImmutableMap.of("Foo", fooInput);
    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) 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 27 with BatchLabelInput

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

the class PostLabelsIT method cannotCreateTwoLabelsWithConflictingNames.

@Test
public void cannotCreateTwoLabelsWithConflictingNames() throws Exception {
    LabelDefinitionInput foo1Input = new LabelDefinitionInput();
    foo1Input.name = "Foo";
    foo1Input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    LabelDefinitionInput foo2Input = new LabelDefinitionInput();
    foo2Input.name = "foo";
    foo2Input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    BatchLabelInput input = new BatchLabelInput();
    input.create = ImmutableList.of(foo1Input, foo2Input);
    ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.projects().name(project.get()).labels(input));
    assertThat(thrown).hasMessageThat().contains("label foo conflicts with existing label Foo");
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) 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