use of com.google.gerrit.extensions.common.LabelDefinitionInput 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);
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput 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");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput 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);
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method createLabels.
@Test
public void createLabels() throws Exception {
LabelDefinitionInput fooInput = new LabelDefinitionInput();
fooInput.name = "Foo";
fooInput.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
LabelDefinitionInput barInput = new LabelDefinitionInput();
barInput.name = "Bar";
barInput.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
BatchLabelInput input = new BatchLabelInput();
input.create = ImmutableList.of(fooInput, barInput);
gApi.projects().name(allProjects.get()).labels(input);
assertThat(gApi.projects().name(allProjects.get()).label("Foo").get()).isNotNull();
assertThat(gApi.projects().name(allProjects.get()).label("Bar").get()).isNotNull();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method cannotSetCommitMessageOnLabelDefinitionInputForCreate.
@Test
public void cannotSetCommitMessageOnLabelDefinitionInputForCreate() throws Exception {
LabelDefinitionInput labelInput = new LabelDefinitionInput();
labelInput.name = "Foo";
labelInput.commitMessage = "Create Label Foo";
BatchLabelInput input = new BatchLabelInput();
input.create = ImmutableList.of(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");
}
Aggregations