Search in sources :

Example 16 with SubmitRequirementResultInfo

use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.

the class SubmitRequirementIT method submitRequirement_nonApplicable_submittabilityAndOverrideNotEvaluated.

@Test
public void submitRequirement_nonApplicable_submittabilityAndOverrideNotEvaluated() throws Exception {
    configSubmitRequirement(project, SubmitRequirement.builder().setName("Code-Review").setApplicabilityExpression(SubmitRequirementExpression.of("branch:refs/heads/non-existent")).setSubmittabilityExpression(SubmitRequirementExpression.maxCodeReview()).setOverrideExpression(SubmitRequirementExpression.of("project:" + project.get())).setAllowOverrideInChildProjects(false).build());
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    voteLabel(changeId, "Code-Review", 2);
    ChangeInfo changeInfo = gApi.changes().id(changeId).get();
    assertSubmitRequirementStatus(changeInfo.submitRequirements, "Code-Review", Status.NOT_APPLICABLE, /* isLegacy= */
    false);
    SubmitRequirementResultInfo requirement = changeInfo.submitRequirements.stream().collect(MoreCollectors.onlyElement());
    assertSubmitRequirementExpression(requirement.applicabilityExpressionResult, /* expression= */
    null, /* passingAtoms= */
    null, /* failingAtoms= */
    null, /* fulfilled= */
    false);
    assertThat(requirement.submittabilityExpressionResult).isNull();
    assertThat(requirement.overrideExpressionResult).isNull();
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 17 with SubmitRequirementResultInfo

use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.

the class SubmitRequirementIT method legacySubmitRequirementWithIgnoreSelfApproval.

@Test
public void legacySubmitRequirementWithIgnoreSelfApproval() throws Exception {
    LabelType verified = label(LabelId.VERIFIED, value(1, "Passes"), value(0, "No score"), value(-1, "Failed"));
    verified = verified.toBuilder().setIgnoreSelfApproval(true).build();
    try (ProjectConfigUpdate u = updateProject(project)) {
        u.getConfig().upsertLabelType(verified);
        u.save();
    }
    projectOperations.project(project).forUpdate().add(allowLabel(verified.getName()).ref(RefNames.REFS_HEADS + "*").group(REGISTERED_USERS).range(-1, 1)).update();
    // The DefaultSubmitRule emits an "OK" submit record for Verified, while the
    // ignoreSelfApprovalRule emits a "NEED" submit record. The "submit requirements" adapter merges
    // both results and returns the blocking one only.
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    gApi.changes().id(changeId).addReviewer(user.id().toString());
    voteLabel(changeId, verified.getName(), +1);
    ChangeInfo changeInfo = gApi.changes().id(changeId).get();
    Collection<SubmitRequirementResultInfo> submitRequirements = changeInfo.submitRequirements;
    assertSubmitRequirementStatus(submitRequirements, "Verified", Status.UNSATISFIED, /* isLegacy= */
    true);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) LabelType(com.google.gerrit.entities.LabelType) SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

SubmitRequirementResultInfo (com.google.gerrit.extensions.common.SubmitRequirementResultInfo)17 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)16 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)16 Test (org.junit.Test)16 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)12 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)8 SubmitRequirementInput (com.google.gerrit.extensions.common.SubmitRequirementInput)7 SubmitRule (com.google.gerrit.server.rules.SubmitRule)7 LabelType (com.google.gerrit.entities.LabelType)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 Iterables (com.google.common.collect.Iterables)3 MoreCollectors (com.google.common.collect.MoreCollectors)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 ExtensionRegistry (com.google.gerrit.acceptance.ExtensionRegistry)3 NoHttpd (com.google.gerrit.acceptance.NoHttpd)3 UseTimezone (com.google.gerrit.acceptance.UseTimezone)3 VerifyNoPiiInChangeNotes (com.google.gerrit.acceptance.VerifyNoPiiInChangeNotes)3