Search in sources :

Example 6 with BatchLabelInput

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

the class PostLabelsIT method commitMessageIsTrimmed.

@Test
public void commitMessageIsTrimmed() throws Exception {
    BatchLabelInput input = new BatchLabelInput();
    input.commitMessage = " Batch Update Labels ";
    input.delete = ImmutableList.of(LabelId.CODE_REVIEW);
    gApi.projects().name(allProjects.get()).labels(input);
    assertThat(projectOperations.project(allProjects).getHead(RefNames.REFS_CONFIG).getShortMessage()).isEqualTo("Batch Update Labels");
}
Also used : BatchLabelInput(com.google.gerrit.extensions.common.BatchLabelInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with BatchLabelInput

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

the class PostLabelsIT method deleteAndRecreateLabel.

@Test
public void deleteAndRecreateLabel() throws Exception {
    configLabel("Foo", LabelFunction.NO_OP);
    LabelDefinitionInput fooInput = new LabelDefinitionInput();
    fooInput.name = "Foo";
    fooInput.function = LabelFunction.MAX_NO_BLOCK.getFunctionName();
    fooInput.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    BatchLabelInput input = new BatchLabelInput();
    input.delete = ImmutableList.of("Foo");
    input.create = ImmutableList.of(fooInput);
    gApi.projects().name(project.get()).labels(input);
    LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("Foo").get();
    assertThat(fooLabel.function).isEqualTo(fooInput.function);
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) 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 8 with BatchLabelInput

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

the class PostLabelsIT method cannotCreateLabelWithoutName.

@Test
public void cannotCreateLabelWithoutName() throws Exception {
    BatchLabelInput input = new BatchLabelInput();
    input.create = ImmutableList.of(new LabelDefinitionInput());
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(allProjects.get()).labels(input));
    assertThat(thrown).hasMessageThat().contains("label name is required for new label");
}
Also used : BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) BatchLabelInput(com.google.gerrit.extensions.common.BatchLabelInput) LabelDefinitionInput(com.google.gerrit.extensions.common.LabelDefinitionInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 9 with BatchLabelInput

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

the class PostLabelsIT method deleteLabels_labelNamesAreTrimmed.

@Test
public void deleteLabels_labelNamesAreTrimmed() 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 10 with BatchLabelInput

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

the class PostLabelsIT method createAndUpdateLabel.

@Test
public void createAndUpdateLabel() throws Exception {
    LabelDefinitionInput fooCreateInput = new LabelDefinitionInput();
    fooCreateInput.name = "Foo";
    fooCreateInput.function = LabelFunction.MAX_NO_BLOCK.getFunctionName();
    fooCreateInput.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
    LabelDefinitionInput fooUpdateInput = new LabelDefinitionInput();
    fooUpdateInput.function = LabelFunction.ANY_WITH_BLOCK.getFunctionName();
    BatchLabelInput input = new BatchLabelInput();
    input.create = ImmutableList.of(fooCreateInput);
    input.update = ImmutableMap.of("Foo", fooUpdateInput);
    gApi.projects().name(project.get()).labels(input);
    LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("Foo").get();
    assertThat(fooLabel.function).isEqualTo(fooUpdateInput.function);
}
Also used : LabelDefinitionInfo(com.google.gerrit.extensions.common.LabelDefinitionInfo) 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