use of com.google.gerrit.server.rules.SubmitRule in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirements_eliminatesDuplicatesForLegacyNonMatchingSRs.
@Test
public void submitRequirements_eliminatesDuplicatesForLegacyNonMatchingSRs() throws Exception {
// If a custom/prolog submit rule emits the same label name multiple times, we merge these into
// a single submit requirement result: in this test, we have two different submit rules that
// return the same label name, one as "OK" and the other as "NEED". The submit requirements
// API favours the blocking entry and returns one SR result with status=UNSATISFIED.
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
SubmitRule r2 = createSubmitRule("r2", SubmitRecord.Status.NOT_READY, "CR", SubmitRecord.Label.Status.NEED);
try (Registration registration = extensionRegistry.newRegistration().add(r1).add(r2)) {
ChangeInfo change = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
assertThat(submitRequirements).hasSize(2);
assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
true);
assertSubmitRequirementStatus(submitRequirements, "CR", Status.UNSATISFIED, /* isLegacy= */
true);
}
}
use of com.google.gerrit.server.rules.SubmitRule in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirements_skippedIfLegacySRIsBasedOnOptionalLabel.
@Test
public void submitRequirements_skippedIfLegacySRIsBasedOnOptionalLabel() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.MAY);
try (Registration registration = extensionRegistry.newRegistration().add(r1)) {
ChangeInfo change = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
assertThat(submitRequirements).hasSize(1);
assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
true);
}
}
use of com.google.gerrit.server.rules.SubmitRule in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_notSkippedIfLegacySRIsBasedOnNonOptionalLabel.
@Test
public void submitRequirement_notSkippedIfLegacySRIsBasedOnNonOptionalLabel() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
try (Registration registration = extensionRegistry.newRegistration().add(r1)) {
ChangeInfo change = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
assertThat(submitRequirements).hasSize(2);
assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
true);
assertSubmitRequirementStatus(submitRequirements, "CR", Status.SATISFIED, /* isLegacy= */
true);
}
}
use of com.google.gerrit.server.rules.SubmitRule in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirements_eliminatesDuplicatesForLegacyMatchingSRs.
@Test
public void submitRequirements_eliminatesDuplicatesForLegacyMatchingSRs() throws Exception {
// If a custom/prolog submit rule emits the same label name multiple times, we merge these into
// a single submit requirement result: in this test, we have two different submit rules that
// return the same label name, but both are fulfilled (i.e. they both allow submission). The
// submit requirements API returns one SR result with status=SATISFIED.
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
SubmitRule r2 = createSubmitRule("r2", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.MAY);
try (Registration registration = extensionRegistry.newRegistration().add(r1).add(r2)) {
ChangeInfo change = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
assertThat(submitRequirements).hasSize(2);
assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
true);
assertSubmitRequirementStatus(submitRequirements, "CR", Status.SATISFIED, /* isLegacy= */
true);
}
}
Aggregations