use of com.google.gerrit.entities.LabelType in project gerrit by GerritCodeReview.
the class ChangeEditIT method editCommitMessageCopiesLabelScores.
@Test
public void editCommitMessageCopiesLabelScores() throws Exception {
String cr = LabelId.CODE_REVIEW;
try (ProjectConfigUpdate u = updateProject(project)) {
LabelType codeReview = TestLabels.codeReview();
u.getConfig().upsertLabelType(codeReview);
u.getConfig().updateLabelType(codeReview.getName(), lt -> lt.setCopyAllScoresIfNoCodeChange(true));
u.save();
}
ReviewInput r = new ReviewInput();
r.labels = ImmutableMap.of(cr, (short) 1);
gApi.changes().id(changeId).current().review(r);
createEmptyEditFor(changeId);
String newSubj = "New commit message";
String newMsg = newSubj + "\n\nChange-Id: " + changeId + "\n";
gApi.changes().id(changeId).edit().modifyCommitMessage(newMsg);
PublishChangeEditInput publishInput = new PublishChangeEditInput();
publishInput.notify = NotifyHandling.NONE;
gApi.changes().id(changeId).edit().publish(publishInput);
ChangeInfo info = get(changeId, DETAILED_LABELS);
assertThat(info.subject).isEqualTo(newSubj);
List<ApprovalInfo> approvals = info.labels.get(cr).all;
assertThat(approvals).hasSize(1);
assertThat(approvals.get(0).value).isEqualTo(1);
}
use of com.google.gerrit.entities.LabelType in project gerrit by GerritCodeReview.
the class SchemaCreatorImplTest method assertValueRange.
private void assertValueRange(LabelType label, Integer... range) {
List<Integer> rangeList = Arrays.asList(range);
assertThat(rangeList).isNotEmpty();
assertThat(rangeList).isInStrictOrder();
assertThat(label.getValues().stream().map(v -> (int) v.getValue())).containsExactlyElementsIn(rangeList).inOrder();
assertThat(label.getMax().getValue()).isEqualTo(Collections.max(rangeList));
assertThat(label.getMin().getValue()).isEqualTo(Collections.min(rangeList));
for (LabelValue v : label.getValues()) {
assertThat(v.getText()).isNotNull();
assertThat(v.getText()).isNotEmpty();
}
}
use of com.google.gerrit.entities.LabelType in project gerrit by GerritCodeReview.
the class SchemaCreatorImplTest method createSchema_LabelTypes.
@Test
public void createSchema_LabelTypes() throws Exception {
List<String> labels = new ArrayList<>();
for (LabelType label : getLabelTypes().getLabelTypes()) {
labels.add(label.getName());
}
assertThat(labels).containsExactly("Code-Review");
}
use of com.google.gerrit.entities.LabelType in project gerrit by GerritCodeReview.
the class ReviewCommand method parseCommandLine.
@Override
protected void parseCommandLine(DynamicOptions pluginOptions) throws UnloggedFailure {
optionMap = new LinkedHashMap<>();
customLabels = new HashMap<>();
ProjectState allProjectsState;
try {
allProjectsState = projectCache.getAllProjects();
} catch (Exception e) {
throw die("missing " + allProjects.get(), e);
}
for (LabelType type : allProjectsState.getLabelTypes().getLabelTypes()) {
StringBuilder usage = new StringBuilder("score for ").append(type.getName()).append("\n");
for (LabelValue v : type.getValues()) {
usage.append(v.format()).append("\n");
}
optionMap.put(newApproveOption(type, usage.toString()), new LabelSetter(type));
}
super.parseCommandLine(pluginOptions);
}
use of com.google.gerrit.entities.LabelType in project gerrit by GerritCodeReview.
the class ImpersonationIT method voteOnBehalfOfLabelNotPermitted.
@Test
public void voteOnBehalfOfLabelNotPermitted() throws Exception {
try (ProjectConfigUpdate u = updateProject(project)) {
LabelType verified = TestLabels.verified();
u.getConfig().upsertLabelType(verified);
u.save();
}
PushOneCommit.Result r = createChange();
RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
ReviewInput in = new ReviewInput();
in.onBehalfOf = user.id().toString();
in.label(LabelId.VERIFIED, 1);
AuthException thrown = assertThrows(AuthException.class, () -> revision.review(in));
assertThat(thrown).hasMessageThat().contains("not permitted to modify label \"Verified\" on behalf of \"" + in.onBehalfOf + '"');
}
Aggregations