use of com.google.gerrit.extensions.common.LabelDefinitionInfo 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.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class SetLabelIT method functionIsTrimmed.
@Test
public void functionIsTrimmed() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.function = " " + LabelFunction.NO_OP.getFunctionName() + " ";
LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
assertThat(updatedLabel.function).isEqualTo(LabelFunction.NO_OP.getFunctionName());
assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().function).isEqualTo(LabelFunction.NO_OP.getFunctionName());
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class SetLabelIT method setCopyMinScore.
@Test
public void setCopyMinScore() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
assertThat(gApi.projects().name(project.get()).label("foo").get().copyMinScore).isNull();
LabelDefinitionInput input = new LabelDefinitionInput();
input.copyMinScore = true;
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
assertThat(updatedLabel.copyMinScore).isTrue();
assertThat(gApi.projects().name(project.get()).label("foo").get().copyMinScore).isTrue();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class ListLabelsIT method labelWithAllRules.
@Test
public void labelWithAllRules() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
// set rules which are not enabled by default
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType("foo", labelType -> {
labelType.setCopyAnyScore(true);
labelType.setCopyMinScore(true);
labelType.setCopyMaxScore(true);
labelType.setCopyAllScoresIfListOfFilesDidNotChange(true);
labelType.setCopyAllScoresIfNoCodeChange(true);
labelType.setCopyAllScoresOnTrivialRebase(true);
labelType.setCopyAllScoresOnMergeFirstParentUpdate(true);
labelType.setCopyValues(ImmutableList.of((short) -1, (short) 1));
labelType.setIgnoreSelfApproval(true);
});
u.save();
}
List<LabelDefinitionInfo> labels = gApi.projects().name(project.get()).labels().get();
assertThat(labelNames(labels)).containsExactly("foo");
LabelDefinitionInfo fooLabel = Iterables.getOnlyElement(labels);
assertThat(fooLabel.canOverride).isTrue();
assertThat(fooLabel.copyAnyScore).isTrue();
assertThat(fooLabel.copyMinScore).isTrue();
assertThat(fooLabel.copyMaxScore).isTrue();
assertThat(fooLabel.copyAllScoresIfListOfFilesDidNotChange).isTrue();
assertThat(fooLabel.copyAllScoresIfNoChange).isTrue();
assertThat(fooLabel.copyAllScoresIfNoCodeChange).isTrue();
assertThat(fooLabel.copyAllScoresOnTrivialRebase).isTrue();
assertThat(fooLabel.copyAllScoresOnMergeFirstParentUpdate).isTrue();
assertThat(fooLabel.copyValues).containsExactly((short) -1, (short) 1).inOrder();
assertThat(fooLabel.allowPostSubmit).isTrue();
assertThat(fooLabel.ignoreSelfApproval).isTrue();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class ListLabelsIT method labelLimitedToBranches.
@Test
public void labelLimitedToBranches() throws Exception {
configLabel("foo", LabelFunction.NO_OP, ImmutableList.of("refs/heads/master", "^refs/heads/stable-.*"));
List<LabelDefinitionInfo> labels = gApi.projects().name(project.get()).labels().get();
assertThat(labelNames(labels)).containsExactly("foo");
LabelDefinitionInfo fooLabel = Iterables.getOnlyElement(labels);
assertThat(fooLabel.branches).containsExactly("refs/heads/master", "^refs/heads/stable-.*");
}
Aggregations