use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class GetLabelIT 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();
}
LabelDefinitionInfo fooLabel = gApi.projects().name(project.get()).label("foo").get();
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 allProjectsLabels.
@Test
public void allProjectsLabels() throws Exception {
List<LabelDefinitionInfo> labels = gApi.projects().name(allProjects.get()).labels().get();
assertThat(labelNames(labels)).containsExactly(LabelId.CODE_REVIEW);
LabelDefinitionInfo codeReviewLabel = Iterables.getOnlyElement(labels);
LabelAssert.assertCodeReviewLabel(codeReviewLabel);
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class ListLabelsIT method inheritedLabelsOnly.
@Test
public void inheritedLabelsOnly() throws Exception {
List<LabelDefinitionInfo> labels = gApi.projects().name(project.get()).labels().withInherited(true).get();
assertThat(labelNames(labels)).containsExactly(LabelId.CODE_REVIEW);
LabelDefinitionInfo codeReviewLabel = Iterables.getOnlyElement(labels);
LabelAssert.assertCodeReviewLabel(codeReviewLabel);
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class ListLabelsIT method labelWithDescription.
@Test
public void labelWithDescription() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType("foo", labelType -> labelType.setDescription(Optional.of("foo label description")));
u.save();
}
List<LabelDefinitionInfo> labels = gApi.projects().name(project.get()).labels().get();
assertThat(labelNames(labels)).containsExactly("foo");
LabelDefinitionInfo fooLabel = Iterables.getOnlyElement(labels);
assertThat(fooLabel.description).isEqualTo("foo label description");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class ListLabelsIT 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();
}
List<LabelDefinitionInfo> labels = gApi.projects().name(project.get()).labels().get();
assertThat(labelNames(labels)).containsExactly("foo");
LabelDefinitionInfo fooLabel = Iterables.getOnlyElement(labels);
assertThat(fooLabel.defaultValue).isEqualTo(1);
}
Aggregations