use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SshCancellationIT method handleClientDisconnected.
@Test
public void handleClientDisconnected() throws Exception {
ProjectCreationValidationListener projectCreationListener = new ProjectCreationValidationListener() {
@Override
public void validateNewProject(CreateProjectArgs args) throws ValidationException {
throw new RequestCancelledException(RequestStateProvider.Reason.CLIENT_CLOSED_REQUEST, /* cancellationMessage= */
null);
}
};
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
adminSshSession.exec("gerrit create-project " + name("new"));
adminSshSession.assertFailure("Client Closed Request");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method throwingSubmitRequirementPredicate.
@Test
public void throwingSubmitRequirementPredicate() throws Exception {
try (Registration registration = extensionRegistry.newRegistration().add(new ThrowingSubmitRequirementPredicate(), ThrowingSubmitRequirementPredicate.OPERAND)) {
SubmitRequirementExpression expression = SubmitRequirementExpression.create(String.format("is:%s_%s", ThrowingSubmitRequirementPredicate.OPERAND, PLUGIN_NAME));
SubmitRequirementExpressionResult result = evaluator.evaluateExpression(expression, changeData);
assertThat(result.status()).isEqualTo(Status.ERROR);
assertThat(result.errorMessage().get()).isEqualTo(ThrowingSubmitRequirementPredicate.ERROR_MESSAGE);
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class AbstractIndexTests method indexChange.
@Test
@GerritConfig(name = "index.autoReindexIfStale", value = "false")
public void indexChange() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
PushOneCommit.Result change = createChange("first change", "test1.txt", "test1");
String changeId = change.getChangeId();
String changeLegacyId = change.getChange().getId().toString();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
disableChangeIndexWrites();
amendChange(changeId, "second test", "test2.txt", "test2");
assertChangeQuery(change.getChange(), false);
enableChangeIndexWrites();
changeIndexedCounter.clear();
String cmd = Joiner.on(" ").join("gerrit", "index", "changes", changeLegacyId);
adminSshSession.exec(cmd);
adminSshSession.assertSuccess();
changeIndexedCounter.assertReindexOf(changeInfo, 1);
assertChangeQuery(change.getChange(), true);
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class AccountIT method createByAccountCreator.
@Test
public void createByAccountCreator() throws Exception {
RefUpdateCounter refUpdateCounter = new RefUpdateCounter();
try (Registration registration = extensionRegistry.newRegistration().add(refUpdateCounter)) {
Account.Id accountId = createByAccountCreator(1);
refUpdateCounter.assertRefUpdateFor(RefUpdateCounter.projectRef(allUsers, RefNames.refsUsers(accountId)), RefUpdateCounter.projectRef(allUsers, RefNames.REFS_EXTERNAL_IDS), RefUpdateCounter.projectRef(allUsers, RefNames.REFS_SEQUENCES + Sequences.NAME_ACCOUNTS));
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class AccountIT method shouldAllowQueryByUserNameForInactiveUser.
@Test
public void shouldAllowQueryByUserNameForInactiveUser() throws Exception {
AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
Account.Id activatableAccountId = accountOperations.newAccount().inactive().username("foo").create();
accountIndexedCounter.assertReindexOf(activatableAccountId, 1);
}
gApi.changes().query("owner:foo").get();
}
Aggregations