Search in sources :

Example 6 with AddReviewerInput

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

the class ChangeReviewersIT method addReviewer.

private AddReviewerResult addReviewer(String changeId, String reviewer, int expectedStatus) throws Exception {
    AddReviewerInput in = new AddReviewerInput();
    in.reviewer = reviewer;
    return addReviewer(changeId, in, expectedStatus);
}
Also used : AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput)

Example 7 with AddReviewerInput

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

the class ChangeReviewersIT method transitionCcToReviewer.

@Test
public void transitionCcToReviewer() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    AddReviewerInput in = new AddReviewerInput();
    in.reviewer = user.email;
    in.state = CC;
    addReviewer(changeId, in);
    ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
    if (notesMigration.readChanges()) {
        assertReviewers(c, REVIEWER);
        assertReviewers(c, CC, user);
    } else {
        assertReviewers(c, REVIEWER, user);
        assertReviewers(c, CC);
    }
    in.state = REVIEWER;
    addReviewer(changeId, in);
    c = gApi.changes().id(r.getChangeId()).get();
    assertReviewers(c, REVIEWER, user);
    assertReviewers(c, CC);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 8 with AddReviewerInput

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

the class ChangeReviewersIT method notifyDetailsWorkOnPostReviewers.

@Test
public void notifyDetailsWorkOnPostReviewers() throws Exception {
    PushOneCommit.Result r = createChange();
    TestAccount userToNotify = createAccounts(1, "notify-details-post-reviewers").get(0);
    AddReviewerInput addReviewer = new AddReviewerInput();
    addReviewer.reviewer = user.email;
    addReviewer.notify = NotifyHandling.NONE;
    addReviewer.notifyDetails = ImmutableMap.of(RecipientType.TO, new NotifyInfo(ImmutableList.of(userToNotify.email)));
    sender.clear();
    gApi.changes().id(r.getChangeId()).addReviewer(addReviewer);
    assertThat(sender.getMessages()).hasSize(1);
    assertThat(sender.getMessages().get(0).rcpt()).containsExactly(userToNotify.emailAddress);
}
Also used : NotifyInfo(com.google.gerrit.extensions.api.changes.NotifyInfo) TestAccount(com.google.gerrit.acceptance.TestAccount) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 9 with AddReviewerInput

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

the class ChangeReviewersByEmailIT method convertFromCCToReviewer.

@Test
public void convertFromCCToReviewer() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
    PushOneCommit.Result r = createChange();
    AddReviewerInput addInput = new AddReviewerInput();
    addInput.reviewer = toRfcAddressString(acc);
    addInput.state = ReviewerState.CC;
    gApi.changes().id(r.getChangeId()).addReviewer(addInput);
    AddReviewerInput modifyInput = new AddReviewerInput();
    modifyInput.reviewer = addInput.reviewer;
    modifyInput.state = ReviewerState.REVIEWER;
    gApi.changes().id(r.getChangeId()).addReviewer(modifyInput);
    ChangeInfo info = gApi.changes().id(r.getChangeId()).get(EnumSet.of(ListChangesOption.DETAILED_LABELS));
    assertThat(info.reviewers).isEqualTo(ImmutableMap.of(ReviewerState.REVIEWER, ImmutableList.of(acc)));
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 10 with AddReviewerInput

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

the class ChangeReviewersByEmailIT method addByEmail.

@Test
public void addByEmail() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
    for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
        PushOneCommit.Result r = createChange();
        AddReviewerInput input = new AddReviewerInput();
        input.reviewer = toRfcAddressString(acc);
        input.state = state;
        gApi.changes().id(r.getChangeId()).addReviewer(input);
        ChangeInfo info = gApi.changes().id(r.getChangeId()).get(EnumSet.of(ListChangesOption.DETAILED_LABELS));
        assertThat(info.reviewers).isEqualTo(ImmutableMap.of(state, ImmutableList.of(acc)));
        // All reviewers added by email should be removable
        assertThat(info.removableReviewers).isEqualTo(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) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)45 Test (org.junit.Test)38 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)34 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)30 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)15 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)13 ReviewerState (com.google.gerrit.extensions.client.ReviewerState)9 Message (com.google.gerrit.testutil.FakeEmailSender.Message)8 AddReviewerResult (com.google.gerrit.extensions.api.changes.AddReviewerResult)7 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)5 Change (com.google.gerrit.reviewdb.client.Change)5 TestAccount (com.google.gerrit.acceptance.TestAccount)4 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)4 Account (com.google.gerrit.reviewdb.client.Account)4 Project (com.google.gerrit.reviewdb.client.Project)4 Repo (com.google.gerrit.testutil.InMemoryRepositoryManager.Repo)4 OrmException (com.google.gwtorm.server.OrmException)4 ConfigInput (com.google.gerrit.extensions.api.projects.ConfigInput)3 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)3 UpdateException (com.google.gerrit.server.update.UpdateException)3