use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithCopyCondition.
@Test
public void createWithCopyCondition() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.copyCondition = "is:MAX";
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
assertThat(createdLabel.copyCondition).isEqualTo("is:MAX");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class CreateLabelIT method branchesAreTrimmed.
@Test
public void branchesAreTrimmed() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.branches = ImmutableList.of(" refs/heads/master ", " refs/heads/foo/* ", " ^refs/heads/stable-.* ");
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
assertThat(createdLabel.branches).containsExactly("refs/heads/master", "refs/heads/foo/*", "^refs/heads/stable-.*");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class CreateLabelIT method cannotCreateLabelWithDuplicateValues.
@Test
public void cannotCreateLabelWithDuplicateValues() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
// Positive values can be specified as '<value>' or '+<value>'.
input.values = ImmutableMap.of("+1", "Looks Good", "1", "Looks Good", "0", "Don't Know", "-1", "Looks Bad");
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(allProjects.get()).label("Foo").create(input));
assertThat(thrown).hasMessageThat().contains("duplicate value: 1");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithDefaultValue.
@Test
public void createWithDefaultValue() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.defaultValue = 1;
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
assertThat(createdLabel.defaultValue).isEqualTo(input.defaultValue);
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithInvalidCopyCondition.
@Test
public void createWithInvalidCopyCondition() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.copyCondition = "blarg::asd";
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(project.get()).label("Bar").create(input));
assertThat(thrown).hasMessageThat().contains("unable to parse copy condition");
}
Aggregations