use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method cannotSetCommitMessageOnLabelDefinitionInputForUpdate.
@Test
public void cannotSetCommitMessageOnLabelDefinitionInputForUpdate() throws Exception {
LabelDefinitionInput labelInput = new LabelDefinitionInput();
labelInput.commitMessage = "Update label";
BatchLabelInput input = new BatchLabelInput();
input.update = ImmutableMap.of(LabelId.CODE_REVIEW, labelInput);
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.projects().name(allProjects.get()).labels(input));
assertThat(thrown).hasMessageThat().contains("commit message on label definition input not supported");
}
use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method cannotDeleteTheSameLabelTwice.
@Test
public void cannotDeleteTheSameLabelTwice() throws Exception {
configLabel("Foo", LabelFunction.NO_OP);
BatchLabelInput input = new BatchLabelInput();
input.delete = ImmutableList.of("Foo", "Foo");
UnprocessableEntityException thrown = assertThrows(UnprocessableEntityException.class, () -> gApi.projects().name(project.get()).labels(input));
assertThat(thrown).hasMessageThat().contains("label Foo not found");
}
use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method deleteLabels.
@Test
public void deleteLabels() throws Exception {
configLabel("Foo", LabelFunction.NO_OP);
configLabel("Bar", LabelFunction.NO_OP);
assertThat(gApi.projects().name(project.get()).labels().get()).isNotEmpty();
BatchLabelInput input = new BatchLabelInput();
input.delete = ImmutableList.of("Foo", "Bar");
gApi.projects().name(project.get()).labels(input);
assertThat(gApi.projects().name(project.get()).labels().get()).isEmpty();
}
use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method notAllowed.
@Test
public void notAllowed() throws Exception {
projectOperations.project(allProjects).forUpdate().add(allow(Permission.READ).ref(RefNames.REFS_CONFIG).group(REGISTERED_USERS)).update();
requestScopeOperations.setApiUser(user.id());
AuthException thrown = assertThrows(AuthException.class, () -> gApi.projects().name(allProjects.get()).labels(new BatchLabelInput()));
assertThat(thrown).hasMessageThat().contains("write refs/meta/config not permitted");
}
use of com.google.gerrit.extensions.common.BatchLabelInput in project gerrit by GerritCodeReview.
the class PostLabelsIT method anonymous.
@Test
public void anonymous() throws Exception {
requestScopeOperations.setApiUserAnonymous();
AuthException thrown = assertThrows(AuthException.class, () -> gApi.projects().name(allProjects.get()).labels(new BatchLabelInput()));
assertThat(thrown).hasMessageThat().contains("Authentication required");
}
Aggregations