use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithFunction.
@Test
public void createWithFunction() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.function = LabelFunction.NO_OP.getFunctionName();
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("Foo").create(input).get();
assertThat(createdLabel.function).isEqualTo(LabelFunction.NO_OP.getFunctionName());
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithCopyAllScoresOnTrivialRebase.
@Test
public void createWithCopyAllScoresOnTrivialRebase() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.copyAllScoresOnTrivialRebase = true;
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
assertThat(createdLabel.copyAllScoresOnTrivialRebase).isTrue();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method createCopyConditionPerformsGroupVisibilityCheckWhenUserInPredicateIsUsed.
@Test
public void createCopyConditionPerformsGroupVisibilityCheckWhenUserInPredicateIsUsed() throws Exception {
String administratorsUUID = gApi.groups().query("name:Administrators").get().get(0).id;
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.copyCondition = "uploaderin:" + administratorsUUID;
projectOperations.project(project).forUpdate().add(allow(Permission.OWNER).ref("refs/*").group(REGISTERED_USERS)).update();
// User can't see admin group
requestScopeOperations.setApiUser(user.id());
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(project.get()).label("foo").create(input));
assertThat(thrown).hasMessageThat().contains("Group " + administratorsUUID + " not found");
// Admin can see admin group
requestScopeOperations.setApiUser(admin.id());
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
assertThat(updatedLabel.copyCondition).isEqualTo(input.copyCondition);
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithoutIgnoreSelfApproval.
@Test
public void createWithoutIgnoreSelfApproval() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.ignoreSelfApproval = false;
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
assertThat(createdLabel.ignoreSelfApproval).isNull();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInfo in project gerrit by GerritCodeReview.
the class CreateLabelIT method createWithoutCopyAnyScore.
@Test
public void createWithoutCopyAnyScore() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.values = ImmutableMap.of("+1", "Looks Good", " 0", "Don't Know", "-1", "Looks Bad");
input.copyAnyScore = false;
LabelDefinitionInfo createdLabel = gApi.projects().name(project.get()).label("foo").create(input).get();
assertThat(createdLabel.copyAnyScore).isNull();
}
Aggregations