Search in sources :

Example 1 with FakeSubmitRule

use of com.google.gerrit.acceptance.FakeSubmitRule in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method bySubmitRuleResult.

@Test
public void bySubmitRuleResult() throws Exception {
    if (getSchemaVersion() < 68) {
        assertMissingField(ChangeField.SUBMIT_RULE_RESULT);
        return;
    }
    try (Registration registration = extensionRegistry.newRegistration().add(new FakeSubmitRule())) {
        TestRepository<Repo> repo = createProject("repo");
        Change change = insert(repo, newChange(repo));
        // The fake submit rule exports its ruleName as "FakeSubmitRule"
        assertQuery("rule:FakeSubmitRule");
        // FakeSubmitRule returns true if change has one or more hashtags.
        HashtagsInput hashtag = new HashtagsInput();
        hashtag.add = ImmutableSet.of("Tag1");
        gApi.changes().id(change.getId().get()).setHashtags(hashtag);
        assertQuery("rule:FakeSubmitRule", change);
        assertQuery("rule:FakeSubmitRule=OK", change);
        assertQuery("rule:FakeSubmitRule=NOT_READY");
    }
}
Also used : Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) HashtagsInput(com.google.gerrit.extensions.api.changes.HashtagsInput) FakeSubmitRule(com.google.gerrit.acceptance.FakeSubmitRule) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 2 with FakeSubmitRule

use of com.google.gerrit.acceptance.FakeSubmitRule in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method byNonExistingSubmitRule_returnsEmpty.

@Test
public void byNonExistingSubmitRule_returnsEmpty() throws Exception {
    // this case.
    if (getSchemaVersion() < 68) {
        assertMissingField(ChangeField.SUBMIT_RULE_RESULT);
        return;
    }
    try (Registration registration = extensionRegistry.newRegistration().add(new FakeSubmitRule())) {
        TestRepository<Repo> repo = createProject("repo");
        insert(repo, newChange(repo));
        assertQuery("rule:non-existent-rule");
    }
}
Also used : Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) FakeSubmitRule(com.google.gerrit.acceptance.FakeSubmitRule) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) Test(org.junit.Test)

Aggregations

Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)2 FakeSubmitRule (com.google.gerrit.acceptance.FakeSubmitRule)2 Repo (com.google.gerrit.testing.InMemoryRepositoryManager.Repo)2 Test (org.junit.Test)2 Change (com.google.gerrit.entities.Change)1 HashtagsInput (com.google.gerrit.extensions.api.changes.HashtagsInput)1