use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method functionEmptyAfterTrim.
@Test
public void functionEmptyAfterTrim() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.function = " ";
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
assertThat(createdLabel.function).isEqualTo(LabelFunction.MAX_WITH_BLOCK.getFunctionName());
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithCopyAllScoresIfNoCodeChange.
@Test
public void createWithCopyAllScoresIfNoCodeChange() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.copyAllScoresIfNoCodeChange = true;
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
assertThat(createdLabel.copyAllScoresIfNoCodeChange).isTrue();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithNameAndDescription.
@Test
public void createWithNameAndDescription() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.description = "Foo label description";
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
assertThat(createdLabel.name).isEqualTo("Foo");
assertThat(createdLabel.description).isEqualTo("Foo label description");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class LabelDefinitionJson method format.
public static LabelDefinitionInfo format(Project.NameKey projectName, LabelType labelType) {
LabelDefinitionInfo label = new LabelDefinitionInfo();
label.name = labelType.getName();
label.description = labelType.getDescription().orElse(null);
label.projectName = projectName.get();
label.function = labelType.getFunction().getFunctionName();
label.values = labelType.getValues().stream().collect(toMap(LabelValue::formatValue, LabelValue::getText));
label.defaultValue = labelType.getDefaultValue();
label.branches = labelType.getRefPatterns() != null ? labelType.getRefPatterns() : null;
label.canOverride = toBoolean(labelType.isCanOverride());
label.copyCondition = labelType.getCopyCondition().orElse(null);
label.copyAnyScore = toBoolean(labelType.isCopyAnyScore());
label.copyMinScore = toBoolean(labelType.isCopyMinScore());
label.copyMaxScore = toBoolean(labelType.isCopyMaxScore());
label.copyAllScoresIfListOfFilesDidNotChange = toBoolean(labelType.isCopyAllScoresIfListOfFilesDidNotChange());
label.copyAllScoresIfNoChange = toBoolean(labelType.isCopyAllScoresIfNoChange());
label.copyAllScoresIfNoCodeChange = toBoolean(labelType.isCopyAllScoresIfNoCodeChange());
label.copyAllScoresOnTrivialRebase = toBoolean(labelType.isCopyAllScoresOnTrivialRebase());
label.copyAllScoresOnMergeFirstParentUpdate = toBoolean(labelType.isCopyAllScoresOnMergeFirstParentUpdate());
label.copyValues = labelType.getCopyValues().isEmpty() ? null : labelType.getCopyValues();
label.allowPostSubmit = toBoolean(labelType.isAllowPostSubmit());
label.ignoreSelfApproval = toBoolean(labelType.isIgnoreSelfApproval());
return label;
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class ListLabels method listLabels.
private List<LabelDefinitionInfo> listLabels(ProjectState projectState) {
Collection<LabelType> labelTypes = projectState.getConfig().getLabelSections().values();
List<LabelDefinitionInfo> labels = new ArrayList<>(labelTypes.size());
for (LabelType labelType : labelTypes) {
labels.add(LabelDefinitionJson.format(projectState.getNameKey(), labelType));
}
labels.sort(Comparator.comparing(l -> l.name));
return labels;
}
Aggregations