Search in sources :

Example 66 with Registration

use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.

the class SubmitRequirementIT method projectSubmitRequirementDuplicatesGlobal_overrideAllowed_projectRequirementEvaluated.

@Test
public void projectSubmitRequirementDuplicatesGlobal_overrideAllowed_projectRequirementEvaluated() throws Exception {
    SubmitRequirement globalSubmitRequirement = SubmitRequirement.builder().setName("CoDe-reView").setSubmittabilityExpression(SubmitRequirementExpression.create("topic:test")).setAllowOverrideInChildProjects(true).build();
    try (Registration registration = extensionRegistry.newRegistration().add(globalSubmitRequirement)) {
        configSubmitRequirement(project, SubmitRequirement.builder().setName("Code-Review").setSubmittabilityExpression(SubmitRequirementExpression.maxCodeReview()).setAllowOverrideInChildProjects(false).build());
        PushOneCommit.Result r = createChange();
        String changeId = r.getChangeId();
        // Setting the topic does not satisfy submit requirement, because the project definition is
        // evaluated.
        gApi.changes().id(changeId).topic("test");
        ChangeInfo change = gApi.changes().id(changeId).get();
        assertThat(change.submitRequirements).hasSize(1);
        // There is no mismatch with legacy submit requirement, so the single result is emitted.
        assertSubmitRequirementStatus(change.submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
        false);
        // Voting satisfies the project definition.
        voteLabel(changeId, "Code-Review", 2);
        change = gApi.changes().id(changeId).get();
        assertThat(change.submitRequirements).hasSize(1);
        assertSubmitRequirementStatus(change.submitRequirements, "Code-Review", Status.SATISFIED, /* isLegacy= */
        false);
    }
}
Also used : LegacySubmitRequirement(com.google.gerrit.entities.LegacySubmitRequirement) SubmitRequirement(com.google.gerrit.entities.SubmitRequirement) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 67 with Registration

use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.

the class AccessIT method webLinkNoRefsMetaConfig.

@Test
public void webLinkNoRefsMetaConfig() throws Exception {
    try (Repository repo = repoManager.openRepository(newProjectName);
        Registration registration = newFileHistoryWebLink()) {
        RefUpdate u = repo.updateRef(RefNames.REFS_CONFIG);
        u.setForceUpdate(true);
        assertThat(u.delete()).isEqualTo(Result.FORCED);
        // This should not crash.
        pApi().access();
    }
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) TestRepository(org.eclipse.jgit.junit.TestRepository) Repository(org.eclipse.jgit.lib.Repository) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) RefUpdate(org.eclipse.jgit.lib.RefUpdate) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 68 with Registration

use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.

the class AccessIT method webLink.

@Test
public void webLink() throws Exception {
    try (Registration registration = newFileHistoryWebLink()) {
        ProjectAccessInfo info = pApi().access();
        assertThat(info.configWebLinks).hasSize(1);
        assertThat(info.configWebLinks.get(0).url).isEqualTo("http://view/" + newProjectName + "/project.config");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) ProjectAccessInfo(com.google.gerrit.extensions.api.access.ProjectAccessInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 69 with Registration

use of com.google.gerrit.acceptance.ExtensionRegistry.Registration 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);
    }
}
Also used : SubmitRule(com.google.gerrit.server.rules.SubmitRule) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 70 with Registration

use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.

the class SubmitRequirementIT method testLegacySubmitRequirementDuplicatesGlobalStatusMatches.

private void testLegacySubmitRequirementDuplicatesGlobalStatusMatches(boolean allowOverrideInChildProject) throws Exception {
    SubmitRequirement globalSubmitRequirement = SubmitRequirement.builder().setName("CoDe-reView").setSubmittabilityExpression(SubmitRequirementExpression.create("topic:test")).setAllowOverrideInChildProjects(allowOverrideInChildProject).build();
    try (Registration registration = extensionRegistry.newRegistration().add(globalSubmitRequirement)) {
        PushOneCommit.Result r = createChange();
        String changeId = r.getChangeId();
        // Both are evaluated, but only the global is returned, since both are unsatisfied
        ChangeInfo change = gApi.changes().id(changeId).get();
        assertThat(change.submitRequirements).hasSize(1);
        assertSubmitRequirementStatus(change.submitRequirements, "CoDe-reView", Status.UNSATISFIED, /* isLegacy= */
        false);
        // Both are evaluated, but only the global is returned, since both are satisfied
        voteLabel(changeId, "Code-Review", 2);
        gApi.changes().id(changeId).topic("test");
        change = gApi.changes().id(changeId).get();
        assertThat(change.submitRequirements).hasSize(1);
        assertSubmitRequirementStatus(change.submitRequirements, "CoDe-reView", Status.SATISFIED, /* isLegacy= */
        false);
    }
}
Also used : LegacySubmitRequirement(com.google.gerrit.entities.LegacySubmitRequirement) SubmitRequirement(com.google.gerrit.entities.SubmitRequirement) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit)

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