Search in sources :

Example 6 with HashtagsInput

use of com.google.gerrit.extensions.api.changes.HashtagsInput in project gerrit by GerritCodeReview.

the class HashtagsIT method addAndRemove.

@Test
public void addAndRemove() throws Exception {
    // Adding and remove hashtags in a single request performs correctly.
    PushOneCommit.Result r = createChange();
    addHashtags(r, "tag1", "tag2");
    HashtagsInput input = new HashtagsInput();
    input.add = Sets.newHashSet("tag3", "tag4");
    input.remove = Sets.newHashSet("tag1");
    change(r).setHashtags(input);
    assertThatGet(r).containsExactly("tag2", "tag3", "tag4");
    assertMessage(r, "Hashtags added: tag3, tag4\nHashtag removed: tag1");
    // Adding and removing the same hashtag actually removes it.
    addHashtags(r, "tag1", "tag2");
    input = new HashtagsInput();
    input.add = Sets.newHashSet("tag3", "tag4");
    input.remove = Sets.newHashSet("tag3");
    change(r).setHashtags(input);
    assertThatGet(r).containsExactly("tag1", "tag2", "tag4");
    assertMessage(r, "Hashtag removed: tag3");
}
Also used : HashtagsInput(com.google.gerrit.extensions.api.changes.HashtagsInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with HashtagsInput

use of com.google.gerrit.extensions.api.changes.HashtagsInput 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)

Aggregations

HashtagsInput (com.google.gerrit.extensions.api.changes.HashtagsInput)7 Test (org.junit.Test)4 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)3 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)3 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)1 FakeSubmitRule (com.google.gerrit.acceptance.FakeSubmitRule)1 AttentionSetUpdate (com.google.gerrit.entities.AttentionSetUpdate)1 Change (com.google.gerrit.entities.Change)1 AttentionSetInput (com.google.gerrit.extensions.api.changes.AttentionSetInput)1 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)1 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1 ChangeInfoDifference (com.google.gerrit.extensions.common.ChangeInfoDifference)1 Repo (com.google.gerrit.testing.InMemoryRepositoryManager.Repo)1