Search in sources :

Example 11 with ReviewerInput

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

the class AccountIT method addReviewerToIgnoredChange.

@Test
public void addReviewerToIgnoredChange() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        PushOneCommit.Result r = createChange();
        requestScopeOperations.setApiUser(user.id());
        gApi.changes().id(r.getChangeId()).ignore(true);
        sender.clear();
        requestScopeOperations.setApiUser(admin.id());
        ReviewerInput in = new ReviewerInput();
        in.reviewer = user.email();
        gApi.changes().id(r.getChangeId()).addReviewer(in);
        List<Message> messages = sender.getMessages();
        assertThat(messages).hasSize(0);
    }
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Message(com.google.gerrit.testing.FakeEmailSender.Message) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 12 with ReviewerInput

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

the class AccountIT method ignoreChange.

@Test
public void ignoreChange() throws Exception {
    AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
    try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
        TestAccount user2 = accountCreator.user2();
        accountIndexedCounter.clear();
        PushOneCommit.Result r = createChange();
        ReviewerInput in = new ReviewerInput();
        in.reviewer = user.email();
        gApi.changes().id(r.getChangeId()).addReviewer(in);
        in = new ReviewerInput();
        in.reviewer = user2.email();
        gApi.changes().id(r.getChangeId()).addReviewer(in);
        requestScopeOperations.setApiUser(user.id());
        gApi.changes().id(r.getChangeId()).ignore(true);
        sender.clear();
        requestScopeOperations.setApiUser(admin.id());
        gApi.changes().id(r.getChangeId()).abandon();
        List<Message> messages = sender.getMessages();
        assertThat(messages).hasSize(1);
        assertThat(messages.get(0).rcpt()).containsExactly(user2.getNameEmail());
        accountIndexedCounter.assertNoReindex();
    }
}
Also used : AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Message(com.google.gerrit.testing.FakeEmailSender.Message) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) TestAccount(com.google.gerrit.acceptance.TestAccount) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 13 with ReviewerInput

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

the class OutgoingEmailIT method htmlAndPlainTextSuffixAddedToMessageId.

@Test
public void htmlAndPlainTextSuffixAddedToMessageId() throws Exception {
    PushOneCommit.Result result = createChange();
    GeneralPreferencesInfo generalPreferencesInfo = new GeneralPreferencesInfo();
    generalPreferencesInfo.emailFormat = GeneralPreferencesInfo.EmailFormat.PLAINTEXT;
    gApi.accounts().id(user.id().get()).setPreferences(generalPreferencesInfo);
    ReviewerInput reviewerInput = new ReviewerInput();
    reviewerInput.reviewer = user.email();
    gApi.changes().id(result.getChangeId()).addReviewer(reviewerInput);
    sender.clear();
    gApi.changes().id(result.getChangeId()).current().review(ReviewInput.approve());
    assertThat(getMessageId(sender)).contains("-PLAIN");
    sender.clear();
    generalPreferencesInfo.emailFormat = GeneralPreferencesInfo.EmailFormat.HTML_PLAINTEXT;
    gApi.accounts().id(user.id().get()).setPreferences(generalPreferencesInfo);
    sender.clear();
    gApi.changes().id(result.getChangeId()).current().review(ReviewInput.reject());
    assertThat(getMessageId(sender)).contains("-HTML");
}
Also used : GeneralPreferencesInfo(com.google.gerrit.extensions.client.GeneralPreferencesInfo) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) Test(org.junit.Test)

Example 14 with ReviewerInput

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

the class ChangeReviewersByEmailIT method addByEmail.

@Test
public void addByEmail() throws Exception {
    AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
    for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
        PushOneCommit.Result r = createChange();
        ReviewerInput input = new ReviewerInput();
        input.reviewer = toRfcAddressString(acc);
        input.state = state;
        gApi.changes().id(r.getChangeId()).addReviewer(input);
        ChangeInfo info = gApi.changes().id(r.getChangeId()).get(DETAILED_LABELS);
        assertThat(info.reviewers).containsExactly(state, ImmutableList.of(acc));
        // All reviewers added by email should be removable
        assertThat(info.removableReviewers).containsExactly(acc);
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ReviewerState(com.google.gerrit.extensions.client.ReviewerState) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 15 with ReviewerInput

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

the class ChangeReviewersByEmailIT method addExistingCcByEmailShortCircuits.

@Test
public void addExistingCcByEmailShortCircuits() throws Exception {
    PushOneCommit.Result r = createChange();
    ReviewerInput input = new ReviewerInput();
    input.reviewer = "nonexisting@example.com";
    input.state = ReviewerState.CC;
    ReviewerResult result = gApi.changes().id(r.getChangeId()).addReviewer(input);
    assertThat(result.ccs).hasSize(1);
    AccountInfo info = result.ccs.get(0);
    assertThat(info._accountId).isNull();
    assertThat(info.email).isEqualTo(input.reviewer);
    assertThat(gApi.changes().id(r.getChangeId()).addReviewer(input).ccs).isEmpty();
}
Also used : ReviewerResult(com.google.gerrit.extensions.api.changes.ReviewerResult) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)72 Test (org.junit.Test)67 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)60 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)46 DeleteReviewerInput (com.google.gerrit.extensions.api.changes.DeleteReviewerInput)25 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)22 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)20 TestAccount (com.google.gerrit.acceptance.TestAccount)14 Message (com.google.gerrit.testing.FakeEmailSender.Message)14 ReviewerResult (com.google.gerrit.extensions.api.changes.ReviewerResult)13 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)11 ReviewerState (com.google.gerrit.extensions.client.ReviewerState)11 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)10 Account (com.google.gerrit.entities.Account)10 Change (com.google.gerrit.entities.Change)7 UseClockStep (com.google.gerrit.acceptance.UseClockStep)5 ReviewerInfo (com.google.gerrit.extensions.api.changes.ReviewerInfo)5 Repo (com.google.gerrit.testing.InMemoryRepositoryManager.Repo)5 Instant (java.time.Instant)5 ArrayList (java.util.ArrayList)5