Search in sources :

Example 56 with ReviewerInput

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

the class ChangesRestApiBindingsIT method reviewerEndpoints.

@Test
public void reviewerEndpoints() throws Exception {
    String changeId = createChange().getChangeId();
    ReviewerInput reviewerInput = new ReviewerInput();
    reviewerInput.reviewer = user.email();
    RestApiCallHelper.execute(adminRestSession, REVIEWER_ENDPOINTS, () -> gApi.changes().id(changeId).addReviewer(reviewerInput), changeId, reviewerInput.reviewer);
}
Also used : ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 57 with ReviewerInput

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

the class ChangeReviewersIT method addExistingReviewerShortCircuits.

@Test
public void addExistingReviewerShortCircuits() throws Exception {
    PushOneCommit.Result r = createChange();
    ReviewerInput input = new ReviewerInput();
    input.reviewer = user.email();
    input.state = ReviewerState.REVIEWER;
    ReviewerResult result = gApi.changes().id(r.getChangeId()).addReviewer(input);
    assertThat(result.reviewers).hasSize(1);
    ReviewerInfo info = result.reviewers.get(0);
    assertThat(info._accountId).isEqualTo(user.id().get());
    assertThat(gApi.changes().id(r.getChangeId()).addReviewer(input).reviewers).isEmpty();
}
Also used : ReviewerResult(com.google.gerrit.extensions.api.changes.ReviewerResult) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) ReviewerInfo(com.google.gerrit.extensions.api.changes.ReviewerInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 58 with ReviewerInput

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

the class ChangeReviewersIT method moveCcToReviewer.

@Test
public void moveCcToReviewer() throws Exception {
    // Create a change and add 'user' as CC.
    String changeId = createChange().getChangeId();
    ReviewerInput reviewerInput = new ReviewerInput();
    reviewerInput.reviewer = user.email();
    reviewerInput.state = ReviewerState.CC;
    gApi.changes().id(changeId).addReviewer(reviewerInput);
    // Verify that 'user' is a CC on the change and that there are no reviewers.
    ChangeInfo c = gApi.changes().id(changeId).get();
    Collection<AccountInfo> ccs = c.reviewers.get(CC);
    assertThat(ccs).isNotNull();
    assertThat(ccs).hasSize(1);
    assertThat(ccs.iterator().next()._accountId).isEqualTo(user.id().get());
    assertThat(c.reviewers.get(REVIEWER)).isNull();
    // Move 'user' from CC to reviewer.
    gApi.changes().id(changeId).addReviewer(user.id().toString());
    // Verify that 'user' is a reviewer on the change now and that there are no CCs.
    c = gApi.changes().id(changeId).get();
    Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
    assertThat(reviewers).isNotNull();
    assertThat(reviewers).hasSize(1);
    assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.id().get());
    assertThat(c.reviewers.get(CC)).isNull();
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 59 with ReviewerInput

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

the class AttentionSetIT method ccsAreIgnored.

@Test
public void ccsAreIgnored() throws Exception {
    PushOneCommit.Result r = createChange();
    ReviewerInput reviewerInput = new ReviewerInput();
    reviewerInput.state = ReviewerState.CC;
    reviewerInput.reviewer = user.email();
    change(r).addReviewer(reviewerInput);
    assertThat(r.getChange().attentionSet()).isEmpty();
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) DeleteReviewerInput(com.google.gerrit.extensions.api.changes.DeleteReviewerInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 60 with ReviewerInput

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

the class AttentionSetIT method removedCcRemovedFromAttentionSet.

@Test
public void removedCcRemovedFromAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange();
    // Add cc
    ReviewerInput input = new ReviewerInput();
    input.reviewer = user.email();
    input.state = ReviewerState.CC;
    change(r).addReviewer(input);
    // Add them to the attention set
    AttentionSetInput attentionSetInput = new AttentionSetInput();
    attentionSetInput.user = user.email();
    attentionSetInput.reason = "reason";
    change(r).addToAttentionSet(attentionSetInput);
    // Remove them from cc
    change(r).reviewer(user.email()).remove();
    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
    assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer/Cc was removed");
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) DeleteReviewerInput(com.google.gerrit.extensions.api.changes.DeleteReviewerInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

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