use of com.google.gerrit.extensions.common.LabelDefinitionInfo 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.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class SetLabelIT method setCopyCondition.
@Test
public void setCopyCondition() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
assertThat(gApi.projects().name(project.get()).label("foo").get().copyCondition).isNull();
LabelDefinitionInput input = new LabelDefinitionInput();
input.copyCondition = "is:MAX";
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
assertThat(updatedLabel.copyCondition).isEqualTo("is:MAX");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class SetLabelIT method unsetCopyCondition.
@Test
public void unsetCopyCondition() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType("foo", lt -> lt.setCopyCondition("is:MAX"));
u.save();
}
assertThat(gApi.projects().name(project.get()).label("foo").get().copyCondition).isEqualTo("is:MAX");
LabelDefinitionInput input = new LabelDefinitionInput();
input.unsetCopyCondition = true;
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
assertThat(updatedLabel.copyCondition).isNull();
assertThat(gApi.projects().name(project.get()).label("foo").get().copyCondition).isNull();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class GetLabelIT method labelWithDefaultValue.
@Test
public void labelWithDefaultValue() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
// set default value
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType("foo", labelType -> labelType.setDefaultValue((short) 1));
u.save();
}
LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("foo").get();
assertThat(fooLabel.defaultValue).isEqualTo(1);
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class GetLabelIT method labelLimitedToBranches.
@Test
public void labelLimitedToBranches() throws Exception {
configLabel("foo", LabelFunction.NO_OP, ImmutableList.of("refs/heads/master", "^refs/heads/stable-.*"));
LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("foo").get();
assertThat(fooLabel.branches).containsExactly("refs/heads/master", "^refs/heads/stable-.*");
}
Aggregations