use of com.google.gerrit.acceptance.ExtensionRegistry.Registration 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.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirements_eliminatesMultipleDuplicatesForLegacyMatchingSRs.
@Test
public void submitRequirements_eliminatesMultipleDuplicatesForLegacyMatchingSRs() 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 five different submit rules that
// return the same label name, all with an "OK" status. The submit requirements API returns
// a single SR result with status=SATISFIED.
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
try (Registration registration = extensionRegistry.newRegistration()) {
IntStream.range(0, 5).forEach(i -> registration.add(createSubmitRule("r" + i, SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK)));
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.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method globalSubmitRequirement_duplicateInProjectConfig_overrideNotAllowedAllowed_globalResultReturned.
@Test
public void globalSubmitRequirement_duplicateInProjectConfig_overrideNotAllowedAllowed_globalResultReturned() throws Exception {
SubmitRequirement globalSubmitRequirement = createSubmitRequirement(/*name=*/
"config-requirement", /* applicabilityExpr= */
"project:" + project.get(), /*submittabilityExpr= */
"is:true", /* overrideExpr= */
"", /*allowOverrideInChildProjects*/
false);
try (Registration registration = extensionRegistry.newRegistration().add(globalSubmitRequirement)) {
SubmitRequirement projectSubmitRequirement = createSubmitRequirement(/*name=*/
"config-requirement", /* applicabilityExpr= */
"project:" + project.get(), /*submittabilityExpr= */
"is:true", /* overrideExpr= */
"", /*allowOverrideInChildProjects*/
false);
configSubmitRequirement(project, projectSubmitRequirement);
Map<SubmitRequirement, SubmitRequirementResult> results = evaluator.evaluateAllRequirements(changeData, /* includeLegacy= */
false);
assertThat(results).hasSize(1);
assertThat(results.get(globalSubmitRequirement).status()).isEqualTo(SubmitRequirementResult.Status.SATISFIED);
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SshCancellationIT method handleWrappedRequestCancelledException.
@Test
public void handleWrappedRequestCancelledException() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
throw new RuntimeException(new RequestCancelledException(RequestStateProvider.Reason.SERVER_DEADLINE_EXCEEDED, "deadline = 10m"));
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
adminSshSession.exec("gerrit create-project " + name("new"));
adminSshSession.assertFailure("Server Deadline Exceeded (deadline = 10m)");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SshCancellationIT method handleServerDeadlineExceeded.
@Test
public void handleServerDeadlineExceeded() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
throw new RequestCancelledException(RequestStateProvider.Reason.SERVER_DEADLINE_EXCEEDED, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
adminSshSession.exec("gerrit create-project " + name("new"));
adminSshSession.assertFailure("Server Deadline Exceeded");
}
}
Aggregations