Search in sources :

Example 76 with Registration

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");
    }
}
Also used : ProjectCreationValidationListener(com.google.gerrit.server.validators.ProjectCreationValidationListener) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) RequestCancelledException(com.google.gerrit.server.cancellation.RequestCancelledException) CreateProjectArgs(com.google.gerrit.server.project.CreateProjectArgs) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 77 with Registration

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);
    }
}
Also used : SubmitRequirementExpression(com.google.gerrit.entities.SubmitRequirementExpression) SubmitRequirementExpressionResult(com.google.gerrit.entities.SubmitRequirementExpressionResult) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 78 with Registration

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);
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ChangeIndexedCounter(com.google.gerrit.acceptance.ChangeIndexedCounter) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 79 with Registration

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));
    }
}
Also used : TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 80 with Registration

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();
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)205 Test (org.junit.Test)200 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)194 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)90 AccountIndexedCounter (com.google.gerrit.acceptance.AccountIndexedCounter)47 RestResponse (com.google.gerrit.acceptance.RestResponse)39 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)38 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)31 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)23 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)22 TestAccount (com.google.gerrit.acceptance.TestAccount)19 PublicKeyStore.keyToString (com.google.gerrit.gpg.PublicKeyStore.keyToString)19 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)16 RequestCancelledException (com.google.gerrit.server.cancellation.RequestCancelledException)15 Config (org.eclipse.jgit.lib.Config)14 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)12 CreateProjectArgs (com.google.gerrit.server.project.CreateProjectArgs)11 ProjectCreationValidationListener (com.google.gerrit.server.validators.ProjectCreationValidationListener)11 RevCommit (org.eclipse.jgit.revwalk.RevCommit)11 ImmutableList (com.google.common.collect.ImmutableList)10