use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method unsetCopyAllScoresOnMergeFirstParentUpdate.
@Test
public void unsetCopyAllScoresOnMergeFirstParentUpdate() throws Exception {
configLabel("foo", LabelFunction.NO_OP);
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType("foo", lt -> lt.setCopyAllScoresOnMergeFirstParentUpdate(true));
u.save();
}
assertThat(gApi.projects().name(project.get()).label("foo").get().copyAllScoresOnMergeFirstParentUpdate).isTrue();
LabelDefinitionInput input = new LabelDefinitionInput();
input.copyAllScoresOnMergeFirstParentUpdate = false;
LabelDefinitionInfo updatedLabel = gApi.projects().name(project.get()).label("foo").update(input);
assertThat(updatedLabel.copyAllScoresOnMergeFirstParentUpdate).isNull();
assertThat(gApi.projects().name(project.get()).label("foo").get().copyAllScoresOnMergeFirstParentUpdate).isNull();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method branchesAreAutomaticallyPrefixedWithRefsHeads.
@Test
public void branchesAreAutomaticallyPrefixedWithRefsHeads() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.branches = ImmutableList.of("master", "refs/meta/config");
LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
assertThat(updatedLabel.branches).containsExactly("refs/heads/master", "refs/meta/config");
assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().branches).containsExactly("refs/heads/master", "refs/meta/config");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT 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()).label(LabelId.CODE_REVIEW).update(new LabelDefinitionInput()));
assertThat(thrown).hasMessageThat().contains("write refs/meta/config not permitted");
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method updateDescription.
@Test
public void updateDescription() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.description = "Code review label description";
LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
assertThat(updatedLabel.description).isEqualTo("Code review label description");
input.description = "";
updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
assertThat(updatedLabel.description).isNull();
}
use of com.google.gerrit.extensions.common.LabelDefinitionInput in project gerrit by GerritCodeReview.
the class SetLabelIT method emptyBranchesAreIgnored.
@Test
public void emptyBranchesAreIgnored() throws Exception {
LabelDefinitionInput input = new LabelDefinitionInput();
input.branches = ImmutableList.of("refs/heads/master", "", " ");
LabelDefinitionInfo updatedLabel = gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).update(input);
assertThat(updatedLabel.branches).containsExactly("refs/heads/master");
assertThat(gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).get().branches).containsExactly("refs/heads/master");
}
Aggregations