Search in sources :

Example 41 with SubmitRequirementResult

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

the class SubmitRequirementsAdapterTest method customSubmitRule_noLabels_withStatusOk.

@Test
public void customSubmitRule_noLabels_withStatusOk() {
    SubmitRecord submitRecord = createSubmitRecord("gerrit~IgnoreSelfApprovalRule", Status.OK, Arrays.asList());
    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 42 with SubmitRequirementResult

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

the class SubmitRequirementsAdapterTest method customSubmitRule_withMixOfPassingAndFailingLabels.

@Test
public void customSubmitRule_withMixOfPassingAndFailingLabels() {
    SubmitRecord submitRecord = createSubmitRecord("gerrit~PrologRule", Status.NOT_READY, Arrays.asList(createLabel("custom-label-1", Label.Status.OK), createLabel("custom-label-2", Label.Status.REJECT)));
    List<SubmitRequirementResult> requirements = SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId, /* isForced= */
    false);
    assertThat(requirements).hasSize(2);
    assertResult(requirements.get(0), /* reqName= */
    "custom-label-1", /* submitExpression= */
    "label:custom-label-1=gerrit~PrologRule", SubmitRequirementResult.Status.SATISFIED, SubmitRequirementExpressionResult.Status.PASS);
    assertResult(requirements.get(1), /* reqName= */
    "custom-label-2", /* submitExpression= */
    "label:custom-label-2=gerrit~PrologRule", SubmitRequirementResult.Status.UNSATISFIED, SubmitRequirementExpressionResult.Status.FAIL);
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) Test(org.junit.Test)

Example 43 with SubmitRequirementResult

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

the class SubmitRequirementsAdapterTest method customSubmitRule_noLabels_withStatusNotReady.

@Test
public void customSubmitRule_noLabels_withStatusNotReady() {
    SubmitRecord submitRecord = createSubmitRecord("gerrit~IgnoreSelfApprovalRule", Status.NOT_READY, Arrays.asList());
    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.UNSATISFIED, SubmitRequirementExpressionResult.Status.FAIL);
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) Test(org.junit.Test)

Example 44 with SubmitRequirementResult

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

the class SubmitRequirementsAdapterTest method defaultSubmitRule_withNonExistingLabel.

@Test
public void defaultSubmitRule_withNonExistingLabel() throws Exception {
    SubmitRecord submitRecord = createSubmitRecord(DefaultSubmitRule.RULE_NAME, Status.OK, Arrays.asList(createLabel("Non-Existing", Label.Status.OK)));
    List<SubmitRequirementResult> requirements = SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId, /* isForced= */
    false);
    assertThat(requirements).isEmpty();
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) Test(org.junit.Test)

Example 45 with SubmitRequirementResult

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

the class SubmitRequirementsAdapterTest method defaultSubmitRule_withLabelsAllNeed.

@Test
public void defaultSubmitRule_withLabelsAllNeed() {
    SubmitRecord submitRecord = createSubmitRecord(DefaultSubmitRule.RULE_NAME, Status.OK, Arrays.asList(createLabel("Code-Review", Label.Status.NEED), createLabel("Verified", Label.Status.NEED)));
    List<SubmitRequirementResult> requirements = SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId, /* isForced= */
    false);
    assertThat(requirements).hasSize(2);
    assertResult(requirements.get(0), /* reqName= */
    "Code-Review", /* submitExpression= */
    "label:Code-Review=MAX -label:Code-Review=MIN", SubmitRequirementResult.Status.UNSATISFIED, SubmitRequirementExpressionResult.Status.FAIL);
    assertResult(requirements.get(1), /* reqName= */
    "Verified", /* submitExpression= */
    "label:Verified=MAX", SubmitRequirementResult.Status.UNSATISFIED, SubmitRequirementExpressionResult.Status.FAIL);
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) Test(org.junit.Test)

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