use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method valuesAndDescriptionsAreTrimmed.
@Test
public void valuesAndDescriptionsAreTrimmed() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
// Positive values can be specified as '<value>' or '+<value>'.
input.values = ImmutableMap.of(" 2 ", " Looks Very Good ", " +1 ", " Looks Good ", " 0 ", " Don't Know ", " -1 ", " Looks Bad ", " -2 ", " Looks Very Bad ");
LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
assertThat(updatedLabel.values).containsExactly("+2", "Looks Very Good", "+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad", "-2", "Looks Very Bad");
assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().values).containsExactly("+2", "Looks Very Good", "+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad", "-2", "Looks Very Bad");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method setAllowPostSubmit.
@Test
public void setAllowPostSubmit() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType("foo", lt -> lt.setAllowPostSubmit(false));
u.save();
}
assertThat(gApi.projects().name(project.get()).label("foo").get().allowPostSubmit).isNull();
LabelDefinitionInput input = new LabelDefinitionInput();
input.allowPostSubmit = true;
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
assertThat(updatedLabel.allowPostSubmit).isTrue();
assertThat(gApi.projects().name(project.get()).label("foo").get().allowPostSubmit).isTrue();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method unsetIgnoreSelfApproval.
@Test
public void unsetIgnoreSelfApproval() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType("foo", lt -> lt.setIgnoreSelfApproval(true));
u.save();
}
assertThat(gApi.projects().name(project.get()).label("foo").get().ignoreSelfApproval).isTrue();
LabelDefinitionInput input = new LabelDefinitionInput();
input.ignoreSelfApproval = false;
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
assertThat(updatedLabel.ignoreSelfApproval).isNull();
assertThat(gApi.projects().name(project.get()).label("foo").get().ignoreSelfApproval).isNull();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method setCopyAllScoresIfNoCodeChange.
@Test
public void setCopyAllScoresIfNoCodeChange() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
assertThat(gApi.projects().name(project.get()).label("foo").get().copyAllScoresIfNoCodeChange).isNull();
LabelDefinitionInput input = new LabelDefinitionInput();
input.copyAllScoresIfNoCodeChange = true;
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
assertThat(updatedLabel.copyAllScoresIfNoCodeChange).isTrue();
assertThat(gApi.projects().name(project.get()).label("foo").get().copyAllScoresIfNoCodeChange).isTrue();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method cannotSetInvalidName.
@Test
public void cannotSetInvalidName() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.name = "INVALID_NAME";
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input));
assertThat(thrown).hasMessageThat().contains("invalid name: " + input.name);
}
Aggregations