Search in sources :

Example 1 with SubmitRequirementInput

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

the class SubmitRequirementIT method checkSubmitRequirement_satisfied.

@Test
public void checkSubmitRequirement_satisfied() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* submittabilityExpression= */
    "label:Code-Review=+2");
    SubmitRequirementResultInfo result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.UNSATISFIED);
    voteLabel(changeId, "Code-Review", 2);
    result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.SATISFIED);
}
Also used : SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) SubmitRequirementInput(com.google.gerrit.extensions.common.SubmitRequirementInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with SubmitRequirementInput

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

the class SubmitRequirementIT method createSubmitRequirementInput.

private static SubmitRequirementInput createSubmitRequirementInput(String name, String submittabilityExpression) {
    SubmitRequirementInput input = new SubmitRequirementInput();
    input.name = name;
    input.submittabilityExpression = submittabilityExpression;
    return input;
}
Also used : SubmitRequirementInput(com.google.gerrit.extensions.common.SubmitRequirementInput)

Example 3 with SubmitRequirementInput

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

the class SubmitRequirementIT method checkSubmitRequirement_notApplicable.

@Test
public void checkSubmitRequirement_notApplicable() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* applicableIf= */
    "branch:non-existent", /* submittableIf= */
    "label:Code-Review=+2", /* overrideIf= */
    null);
    SubmitRequirementResultInfo result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.NOT_APPLICABLE);
    voteLabel(changeId, "Code-Review", 2);
    result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.NOT_APPLICABLE);
}
Also used : SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) SubmitRequirementInput(com.google.gerrit.extensions.common.SubmitRequirementInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with SubmitRequirementInput

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

the class SubmitRequirementIT method checkSubmitRequirement_error.

@Test
public void checkSubmitRequirement_error() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* submittabilityExpression= */
    "!!!");
    SubmitRequirementResultInfo result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.ERROR);
}
Also used : SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) SubmitRequirementInput(com.google.gerrit.extensions.common.SubmitRequirementInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with SubmitRequirementInput

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

the class SubmitRequirementIT method checkSubmitRequirement_overridden.

@Test
public void checkSubmitRequirement_overridden() throws Exception {
    // label function has no effect
    configLabel("Override-Label", LabelFunction.NO_OP);
    projectOperations.project(project).forUpdate().add(allowLabel("Override-Label").ref("refs/heads/master").group(REGISTERED_USERS).range(-1, 1)).update();
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* applicableIf= */
    null, /* submittableIf= */
    "label:Code-Review=+2", /* overrideIf= */
    "label:Override-Label=+1");
    SubmitRequirementResultInfo result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.UNSATISFIED);
    voteLabel(changeId, "Code-Review", 2);
    result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.SATISFIED);
    voteLabel(changeId, "Override-Label", 1);
    result = gApi.changes().id(changeId).checkSubmitRequirement(in);
    assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.OVERRIDDEN);
}
Also used : SubmitRequirementResultInfo(com.google.gerrit.extensions.common.SubmitRequirementResultInfo) SubmitRequirementInput(com.google.gerrit.extensions.common.SubmitRequirementInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

SubmitRequirementInput (com.google.gerrit.extensions.common.SubmitRequirementInput)5 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)4 SubmitRequirementResultInfo (com.google.gerrit.extensions.common.SubmitRequirementResultInfo)4 Test (org.junit.Test)4