Search in sources :

Example 21 with ReviewerState

use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.

the class ChangeReviewersByEmailIT method removeByEmail.

@Test
public void removeByEmail() 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 addInput = new ReviewerInput();
        addInput.reviewer = toRfcAddressString(acc);
        addInput.state = state;
        gApi.changes().id(r.getChangeId()).addReviewer(addInput);
        gApi.changes().id(r.getChangeId()).reviewer(acc.email).remove();
        ChangeInfo info = gApi.changes().id(r.getChangeId()).get(DETAILED_LABELS);
        assertThat(info.reviewers).isEmpty();
    }
}
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 22 with ReviewerState

use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.

the class ChangeReviewersByEmailIT method reviewerAndCCReceiveRegularNotification.

@Test
public void reviewerAndCCReceiveRegularNotification() 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);
        sender.clear();
        gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
        assertNotifyCc(Address.parse(input.reviewer));
    }
}
Also used : 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 23 with ReviewerState

use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.

the class ChangeReviewersByEmailIT method reviewerAndCCReceiveSameEmail.

@Test
public void reviewerAndCCReceiveSameEmail() throws Exception {
    PushOneCommit.Result r = createChange();
    for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
        for (int i = 0; i < 10; i++) {
            ReviewerInput input = new ReviewerInput();
            input.reviewer = String.format("%s-%s@gerritcodereview.com", state, i);
            input.state = state;
            gApi.changes().id(r.getChangeId()).addReviewer(input);
        }
    }
    // Also add user as a regular reviewer
    ReviewerInput input = new ReviewerInput();
    input.reviewer = user.email();
    input.state = ReviewerState.REVIEWER;
    gApi.changes().id(r.getChangeId()).addReviewer(input);
    sender.clear();
    gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
    // Assert that only one email was sent out to everyone
    assertThat(sender.getMessages()).hasSize(1);
}
Also used : ReviewerState(com.google.gerrit.extensions.client.ReviewerState) 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 24 with ReviewerState

use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method restorePendingReviewers.

@Test
public void restorePendingReviewers() throws Exception {
    Project.NameKey project = Project.nameKey("repo");
    TestRepository<Repo> repo = createProject(project.get());
    ConfigInput conf = new ConfigInput();
    conf.enableReviewerByEmail = InheritableBoolean.TRUE;
    gApi.projects().name(project.get()).config(conf);
    Change change1 = insert(repo, newChangeWorkInProgress(repo));
    Account.Id user1 = createAccount("user1");
    Account.Id user2 = createAccount("user2");
    String email1 = "email1@example.com";
    String email2 = "email2@example.com";
    ReviewInput in = ReviewInput.noScore().reviewer(user1.toString()).reviewer(user2.toString(), ReviewerState.CC, false).reviewer(email1).reviewer(email2, ReviewerState.CC, false);
    gApi.changes().id(change1.getId().get()).current().review(in);
    List<ChangeInfo> changeInfos = assertQuery(newQuery("is:wip").withOption(DETAILED_LABELS), change1);
    assertThat(changeInfos).isNotEmpty();
    Map<ReviewerState, Collection<AccountInfo>> pendingReviewers = changeInfos.get(0).pendingReviewers;
    assertThat(pendingReviewers).isNotNull();
    assertReviewers(pendingReviewers.get(ReviewerState.REVIEWER), user1.toString(), email1);
    assertReviewers(pendingReviewers.get(ReviewerState.CC), user2.toString(), email2);
    assertReviewers(pendingReviewers.get(ReviewerState.REMOVED));
    // Pending reviewers may also be presented in the REMOVED state. Toggle the
    // change to ready and then back to WIP and remove reviewers to produce.
    assertThat(pendingReviewers.get(ReviewerState.REMOVED)).isNull();
    gApi.changes().id(change1.getId().get()).setReadyForReview();
    gApi.changes().id(change1.getId().get()).setWorkInProgress();
    gApi.changes().id(change1.getId().get()).reviewer(user1.toString()).remove();
    gApi.changes().id(change1.getId().get()).reviewer(user2.toString()).remove();
    gApi.changes().id(change1.getId().get()).reviewer(email1).remove();
    gApi.changes().id(change1.getId().get()).reviewer(email2).remove();
    changeInfos = assertQuery(newQuery("is:wip").withOption(DETAILED_LABELS), change1);
    assertThat(changeInfos).isNotEmpty();
    pendingReviewers = changeInfos.get(0).pendingReviewers;
    assertThat(pendingReviewers).isNotNull();
    assertReviewers(pendingReviewers.get(ReviewerState.REVIEWER));
    assertReviewers(pendingReviewers.get(ReviewerState.CC));
    assertReviewers(pendingReviewers.get(ReviewerState.REMOVED), user1.toString(), user2.toString(), email1, email2);
}
Also used : Account(com.google.gerrit.entities.Account) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ReviewerState(com.google.gerrit.extensions.client.ReviewerState) Change(com.google.gerrit.entities.Change) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Project(com.google.gerrit.entities.Project) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) ChangeIndexCollection(com.google.gerrit.server.index.change.ChangeIndexCollection) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

ReviewerState (com.google.gerrit.extensions.client.ReviewerState)24 Test (org.junit.Test)20 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)19 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)19 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)18 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)11 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)10 Collection (java.util.Collection)10 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)9 List (java.util.List)7 Message (com.google.gerrit.testing.FakeEmailSender.Message)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)4 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)4 NotifyHandling (com.google.gerrit.extensions.api.changes.NotifyHandling)4 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)4 ImmutableList (com.google.common.collect.ImmutableList)3 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)3 ProjectOperations (com.google.gerrit.acceptance.testsuite.project.ProjectOperations)3 RequestScopeOperations (com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations)3 BranchNameKey (com.google.gerrit.entities.BranchNameKey)3