Search in sources :

Example 46 with SubmitRequirementResult

use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.

the class SubmitRequirementsAdapterTest method customSubmitRule_nullLabels_withStatusOk.

@Test
public void customSubmitRule_nullLabels_withStatusOk() {
    SubmitRecord submitRecord = createSubmitRecord("gerrit~IgnoreSelfApprovalRule", Status.OK, /* labels= */
    null);
    List<SubmitRequirementResult> requirements = SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId, /* isForced= */
    false);
    assertThat(requirements).hasSize(1);
    assertResult(requirements.get(0), /* reqName= */
    "gerrit~IgnoreSelfApprovalRule", /* submitExpression= */
    "rule:gerrit~IgnoreSelfApprovalRule", SubmitRequirementResult.Status.SATISFIED, SubmitRequirementExpressionResult.Status.PASS);
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) Test(org.junit.Test)

Example 47 with SubmitRequirementResult

use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.

the class OnStoreSubmitRequirementResultModifierIT method submitRequirementStored_notReturnedWhenHidden.

@Test
public void submitRequirementStored_notReturnedWhenHidden() throws Exception {
    TEST_ON_STORE_SUBMIT_REQUIREMENT_RESULT_MODIFIER.setModificationStrategy(ModificationStrategy.OVERRIDE);
    TEST_ON_STORE_SUBMIT_REQUIREMENT_RESULT_MODIFIER.hide(true);
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    approve(changeId);
    ChangeInfo change = gApi.changes().id(changeId).get();
    assertThat(change.submitRequirements).hasSize(1);
    assertSubmitRequirementStatus(change.submitRequirements, "Code-Review", Status.SATISFIED, /* isLegacy= */
    false);
    gApi.changes().id(changeId).current().submit();
    change = gApi.changes().id(changeId).get();
    assertThat(change.submitRequirements).hasSize(0);
    ChangeNotes notes = notesFactory.create(project, r.getChange().getId());
    SubmitRequirementResult result = notes.getSubmitRequirementsResult().stream().collect(MoreCollectors.onlyElement());
    assertThat(result.submitRequirement().name()).isEqualTo("Code-Review");
    assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.OVERRIDDEN);
    assertThat(result.submittabilityExpressionResult().get().expression().expressionString()).isEqualTo("label:Code-Review=MAX");
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

SubmitRequirementResult (com.google.gerrit.entities.SubmitRequirementResult)47 Test (org.junit.Test)36 SubmitRequirement (com.google.gerrit.entities.SubmitRequirement)27 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)21 SubmitRecord (com.google.gerrit.entities.SubmitRecord)14 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)5 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)5 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)5 ChangeData (com.google.gerrit.server.query.change.ChangeData)5 Map (java.util.Map)5 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)3 VerifyNoPiiInChangeNotes (com.google.gerrit.acceptance.VerifyNoPiiInChangeNotes)3 Project (com.google.gerrit.entities.Project)3 Label (com.google.gerrit.entities.SubmitRecord.Label)3 SubmitType (com.google.gerrit.extensions.client.SubmitType)3 HashMap (java.util.HashMap)3 Optional (java.util.Optional)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3