use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method deleteRecreateAndUpdateLabel.
@Test
public void deleteRecreateAndUpdateLabel() throws Exception {
configLabel("Foo", LabelFunction.NO_OP);
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.delete = ImmutableList.of("Foo");
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.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method cannotCreateLabelWithNameThatIsAlreadyInUse.
@Test
public void cannotCreateLabelWithNameThatIsAlreadyInUse() throws Exception {
LabelDefinitionInput labelInput = new LabelDefinitionInput();
labelInput.name = LabelId.CODE_REVIEW;
BatchLabelInput input = new BatchLabelInput();
input.create = ImmutableList.of(labelInput);
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.projects().name(allProjects.get()).labels(input));
assertThat(thrown).hasMessageThat().contains("label Code-Review already exists");
}
use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method cannotCreateTwoLabelsWithNamesThatAreTheSameAfterTrim.
@Test
public void cannotCreateTwoLabelsWithNamesThatAreTheSameAfterTrim() 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 already exists");
}
use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method updateLabels_labelNamesAreTrimmed.
@Test
public void updateLabels_labelNamesAreTrimmed() throws Exception {
configLabel("Foo", LabelFunction.NO_OP);
configLabel("Bar", LabelFunction.NO_OP);
LabelDefinitionInput fooUpdate = new LabelDefinitionInput();
fooUpdate.function = LabelFunction.MAX_WITH_BLOCK.getFunctionName();
LabelDefinitionInput barUpdate = new LabelDefinitionInput();
barUpdate.name = "Baz";
BatchLabelInput input = new BatchLabelInput();
input.update = ImmutableMap.of(" Foo ", fooUpdate, " Bar ", barUpdate);
gApi.projects().name(project.get()).labels(input);
assertThat(gApi.projects().name(project.get()).label("Foo").get().function).isEqualTo(fooUpdate.function);
assertThat(gApi.projects().name(project.get()).label("Baz").get()).isNotNull();
assertThrows(ResourceNotFoundException.class, () -> gApi.projects().name(project.get()).label("Bar").get());
}
use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method createLabels_labelNamesAreTrimmed.
@Test
public void createLabels_labelNamesAreTrimmed() 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();
}
Aggregations