Search in sources :

Example 51 with ReviewerInput

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

the class ChangeIT method addReviewerThatIsInactiveById.

@Test
public void addReviewerThatIsInactiveById() throws Exception {
    PushOneCommit.Result result = createChange();
    String username = name("new-user");
    Account.Id id = accountOperations.newAccount().username(username).inactive().create();
    ReviewerInput in = new ReviewerInput();
    in.reviewer = Integer.toString(id.get());
    ReviewerResult r = gApi.changes().id(result.getChangeId()).addReviewer(in);
    assertThat(r.input).isEqualTo(in.reviewer);
    assertThat(r.error).isNull();
    assertThat(r.reviewers).hasSize(1);
    ReviewerInfo reviewer = r.reviewers.get(0);
    assertThat(reviewer._accountId).isEqualTo(id.get());
    assertThat(reviewer.username).isEqualTo(username);
}
Also used : TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) ReviewerResult(com.google.gerrit.extensions.api.changes.ReviewerResult) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) DeleteReviewerInput(com.google.gerrit.extensions.api.changes.DeleteReviewerInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) ReviewerInfo(com.google.gerrit.extensions.api.changes.ReviewerInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 52 with ReviewerInput

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

the class ChangeIT method addReviewer.

@Test
@UseClockStep
public void addReviewer() throws Exception {
    testAddReviewerViaPostReview((changeId, reviewer) -> {
        ReviewerInput in = new ReviewerInput();
        in.reviewer = reviewer;
        gApi.changes().id(changeId).addReviewer(in);
    });
}
Also used : DeleteReviewerInput(com.google.gerrit.extensions.api.changes.DeleteReviewerInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) UseClockStep(com.google.gerrit.acceptance.UseClockStep)

Example 53 with ReviewerInput

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

the class ChangeReviewersByEmailIT method addByEmailAndById.

@Test
public void addByEmailAndById() throws Exception {
    AccountInfo byEmail = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
    AccountInfo byId = new AccountInfo(user.id().get());
    for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
        PushOneCommit.Result r = createChange();
        ReviewerInput inputByEmail = new ReviewerInput();
        inputByEmail.reviewer = toRfcAddressString(byEmail);
        inputByEmail.state = state;
        gApi.changes().id(r.getChangeId()).addReviewer(inputByEmail);
        ReviewerInput inputById = new ReviewerInput();
        inputById.reviewer = user.email();
        inputById.state = state;
        gApi.changes().id(r.getChangeId()).addReviewer(inputById);
        ChangeInfo info = gApi.changes().id(r.getChangeId()).get(DETAILED_LABELS);
        assertThat(info.reviewers).isEqualTo(ImmutableMap.of(state, ImmutableList.of(byId, byEmail)));
        // All reviewers (both by id and by email) should be removable
        assertThat(info.removableReviewers).containsExactly(byId, byEmail);
    }
}
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 54 with ReviewerInput

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

the class ChangeReviewersByEmailIT method addedReviewersGetNotified.

@Test
public void addedReviewersGetNotified() 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);
        List<Message> messages = sender.getMessages();
        assertThat(messages).hasSize(1);
        assertThat(messages.get(0).rcpt()).containsExactly(Address.parse(input.reviewer));
        sender.clear();
    }
}
Also used : Message(com.google.gerrit.testing.FakeEmailSender.Message) 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 55 with ReviewerInput

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

the class ChangeReviewersByEmailIT method reviewersByEmailAreServedFromIndex.

@Test
public void reviewersByEmailAreServedFromIndex() 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);
        try (AutoCloseable ignored = disableNoteDb()) {
            ChangeInfo info = Iterables.getOnlyElement(gApi.changes().query(r.getChangeId()).withOption(DETAILED_LABELS).get());
            assertThat(info.reviewers).isEqualTo(ImmutableMap.of(state, ImmutableList.of(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)

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