Search in sources :

Example 1 with SubmitRule

use of com.google.gerrit.server.rules.SubmitRule in project gerrit by GerritCodeReview.

the class SubmitRequirementIT method submitRequirements_eliminatesDuplicatesForLegacyNonMatchingSRs.

@Test
public void submitRequirements_eliminatesDuplicatesForLegacyNonMatchingSRs() throws Exception {
    // If a custom/prolog submit rule emits the same label name multiple times, we merge these into
    // a single submit requirement result: in this test, we have two different submit rules that
    // return the same label name, one as "OK" and the other as "NEED". The submit requirements
    // API favours the blocking entry and returns one SR result with status=UNSATISFIED.
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
    SubmitRule r2 = createSubmitRule("r2", SubmitRecord.Status.NOT_READY, "CR", SubmitRecord.Label.Status.NEED);
    try (Registration registration = extensionRegistry.newRegistration().add(r1).add(r2)) {
        ChangeInfo change = gApi.changes().id(changeId).get();
        Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
        assertThat(submitRequirements).hasSize(2);
        assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
        true);
        assertSubmitRequirementStatus(submitRequirements, "CR", 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 2 with SubmitRule

use of com.google.gerrit.server.rules.SubmitRule 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 3 with SubmitRule

use of com.google.gerrit.server.rules.SubmitRule in project gerrit by GerritCodeReview.

the class SubmitRequirementIT method submitRequirement_notSkippedIfLegacySRIsBasedOnNonOptionalLabel.

@Test
public void submitRequirement_notSkippedIfLegacySRIsBasedOnNonOptionalLabel() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
    try (Registration registration = extensionRegistry.newRegistration().add(r1)) {
        ChangeInfo change = gApi.changes().id(changeId).get();
        Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
        assertThat(submitRequirements).hasSize(2);
        assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
        true);
        assertSubmitRequirementStatus(submitRequirements, "CR", Status.SATISFIED, /* 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 4 with SubmitRule

use of com.google.gerrit.server.rules.SubmitRule in project gerrit by GerritCodeReview.

the class SubmitRequirementIT method submitRequirements_eliminatesDuplicatesForLegacyMatchingSRs.

@Test
public void submitRequirements_eliminatesDuplicatesForLegacyMatchingSRs() throws Exception {
    // If a custom/prolog submit rule emits the same label name multiple times, we merge these into
    // a single submit requirement result: in this test, we have two different submit rules that
    // return the same label name, but both are fulfilled (i.e. they both allow submission). The
    // submit requirements API returns one SR result with status=SATISFIED.
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
    SubmitRule r2 = createSubmitRule("r2", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.MAY);
    try (Registration registration = extensionRegistry.newRegistration().add(r1).add(r2)) {
        ChangeInfo change = gApi.changes().id(changeId).get();
        Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
        assertThat(submitRequirements).hasSize(2);
        assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
        true);
        assertSubmitRequirementStatus(submitRequirements, "CR", Status.SATISFIED, /* 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)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)4 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)4 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 SubmitRequirementResultInfo (com.google.gerrit.extensions.common.SubmitRequirementResultInfo)4 SubmitRule (com.google.gerrit.server.rules.SubmitRule)4 Test (org.junit.Test)4