Search in sources :

Example 11 with AttentionSetInput

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

the class AttentionSetIT method readyForReviewWhileRemovingReviewerRemovesThemToAttentionSet.

@Test
public void readyForReviewWhileRemovingReviewerRemovesThemToAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange();
    change(r).setWorkInProgress();
    change(r).addReviewer(user.email());
    ReviewInput reviewInput = ReviewInput.create().setReady(true);
    ReviewerInput reviewerInput = new ReviewerInput();
    reviewerInput.state = ReviewerState.CC;
    reviewerInput.reviewer = user.email();
    reviewInput.reviewers = ImmutableList.of(reviewerInput);
    change(r).addToAttentionSet(new AttentionSetInput(user.email(), "reason"));
    change(r).current().review(reviewInput);
    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
    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) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) 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 12 with AttentionSetInput

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

the class AttentionSetIT method cannotRemoveIrrelevantUserToAttentionSet.

@Test
public void cannotRemoveIrrelevantUserToAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange();
    BadRequestException exception = assertThrows(BadRequestException.class, () -> change(r).attention(user.email()).remove(new AttentionSetInput("reason")));
    assertThat(exception.getMessage()).isEqualTo(String.format("%s doesn't exist or is not active on the change as an owner, uploader, reviewer, " + "or cc so they can't be added to the attention set", user.email()));
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 13 with AttentionSetInput

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

the class AttentionSetIT method canModifyAttentionSetForInvisibleUsersOnVisibleChanges.

@Test
@GerritConfig(name = "accounts.visibility", value = "NONE")
public void canModifyAttentionSetForInvisibleUsersOnVisibleChanges() throws Exception {
    PushOneCommit.Result r = createChange();
    requestScopeOperations.setApiUser(user.id());
    // admin is invisible to the user, but they can still add them to the attention set since they
    // see the change.
    change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "reason"));
    assertThat(Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin)).operation()).isEqualTo(Operation.ADD);
    // admin is invisible to the user, but they can still remove them to the attention set since
    // they see the change.
    change(r).attention(admin.id().toString()).remove(new AttentionSetInput("removed"));
    assertThat(Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin)).operation()).isEqualTo(Operation.REMOVE);
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 14 with AttentionSetInput

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

the class AttentionSetIT method reviewRemovesUserFromAttentionSet.

@Test
public void reviewRemovesUserFromAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange();
    change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "reason"));
    ReviewInput reviewInput = new ReviewInput();
    change(r).current().review(reviewInput);
    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
    assertThat(attentionSet).hasReasonThat().isEqualTo("removed on reply");
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 15 with AttentionSetInput

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

the class AttentionSetIT method cannotAddNonExistingUserToAttentionSet.

@Test
public void cannotAddNonExistingUserToAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange();
    BadRequestException exception = assertThrows(BadRequestException.class, () -> change(r).addToAttentionSet(new AttentionSetInput("INVALID USER", "reason")));
    assertThat(exception.getMessage()).isEqualTo("INVALID USER doesn't exist or is not active on the change as an owner," + " uploader, reviewer, or cc so they can't be added to the attention set");
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AttentionSetInput (com.google.gerrit.extensions.api.changes.AttentionSetInput)34 Test (org.junit.Test)34 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)32 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)31 AttentionSetUpdate (com.google.gerrit.entities.AttentionSetUpdate)21 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)7 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)7 TestAccount (com.google.gerrit.acceptance.TestAccount)5 Change (com.google.gerrit.entities.Change)3 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)3 AttentionSetInfo (com.google.gerrit.extensions.common.AttentionSetInfo)3 Account (com.google.gerrit.entities.Account)2 DeleteReviewerInput (com.google.gerrit.extensions.api.changes.DeleteReviewerInput)2 Repo (com.google.gerrit.testing.InMemoryRepositoryManager.Repo)2 Result (com.google.gerrit.acceptance.PushOneCommit.Result)1 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)1 HashtagsInput (com.google.gerrit.extensions.api.changes.HashtagsInput)1 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)1 GroupInput (com.google.gerrit.extensions.api.groups.GroupInput)1 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1