use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method addUserWithTemplateReason.
@Test
public void addUserWithTemplateReason() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
String manualReason = "Added by " + AccountTemplateUtil.getAccountTemplate(user.id());
int accountId = change(r).addToAttentionSet(new AttentionSetInput(admin.email(), manualReason))._accountId;
assertThat(accountId).isEqualTo(admin.id().get());
AttentionSetUpdate expectedAttentionSetUpdate = AttentionSetUpdate.createFromRead(fakeClock.now(), admin.id(), AttentionSetUpdate.Operation.ADD, manualReason);
assertThat(r.getChange().attentionSet()).containsExactly(expectedAttentionSetUpdate);
AttentionSetInfo attentionSetInfo = Iterables.getOnlyElement(change(r).get().attentionSet.values());
assertThat(attentionSetInfo.reason).isEqualTo(manualReason);
assertThat(attentionSetInfo.reasonAccount).isEqualTo(getAccountInfo(user.id()));
assertThat(attentionSetInfo.account).isEqualTo(getAccountInfo(admin.id()));
AttentionSetInfo getAttentionSetInfo = Iterables.getOnlyElement(getAttentionSet.apply(parseChangeResource(r.getChangeId())).value());
assertThat(getAttentionSetInfo.reason).isEqualTo(manualReason);
assertThat(getAttentionSetInfo.reasonAccount).isEqualTo(getAccountInfo(user.id()));
assertThat(getAttentionSetInfo.account).isEqualTo(getAccountInfo(admin.id()));
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method reviewAddUserToAttentionSetWhileReplyingJustAddsUser.
@Test
public void reviewAddUserToAttentionSetWhileReplyingJustAddsUser() throws Exception {
PushOneCommit.Result r = createChange();
ReviewInput reviewInput = ReviewInput.create().addUserToAttentionSet(admin.email(), "reason");
change(r).current().review(reviewInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method repliesAddOwnerWhenChangeIsBecomingReadyForReview.
@Test
public void repliesAddOwnerWhenChangeIsBecomingReadyForReview() throws Exception {
PushOneCommit.Result r = createChange();
change(r).setWorkInProgress();
requestScopeOperations.setApiUser(accountCreator.admin2().id());
ReviewInput reviewInput = ReviewInput.create().setReady(true);
change(r).current().review(reviewInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("Someone else replied on the change");
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method repliesWhileAddingAsReviewerStillRemovesUser.
@Test
public void repliesWhileAddingAsReviewerStillRemovesUser() throws Exception {
PushOneCommit.Result r = createChange();
// implictly adds the user to the attention set when adding as reviewer
change(r).addReviewer(user.email());
change(r).addToAttentionSet(new AttentionSetInput(user.email(), "remove"));
requestScopeOperations.setApiUser(user.id());
ReviewInput reviewInput = ReviewInput.recommend();
change(r).current().review(reviewInput);
// reviewer removed
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
assertThat(attentionSet).hasReasonThat().isEqualTo("removed on reply");
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method addUserWithTemplateReasonMultipleAccounts.
@Test
public void addUserWithTemplateReasonMultipleAccounts() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
String manualReason = String.format("Added by %s with user %s", AccountTemplateUtil.getAccountTemplate(user.id()), AccountTemplateUtil.getAccountTemplate(admin.id()));
int accountId = change(r).addToAttentionSet(new AttentionSetInput(admin.email(), manualReason))._accountId;
assertThat(accountId).isEqualTo(admin.id().get());
AttentionSetUpdate expectedAttentionSetUpdate = AttentionSetUpdate.createFromRead(fakeClock.now(), admin.id(), AttentionSetUpdate.Operation.ADD, manualReason);
assertThat(r.getChange().attentionSet()).containsExactly(expectedAttentionSetUpdate);
AttentionSetInfo attentionSetInfo = Iterables.getOnlyElement(change(r).get().attentionSet.values());
assertThat(attentionSetInfo.reason).isEqualTo(manualReason);
assertThat(attentionSetInfo.reasonAccount).isNull();
assertThat(attentionSetInfo.account).isEqualTo(getAccountInfo(admin.id()));
AttentionSetInfo getAttentionSetInfo = Iterables.getOnlyElement(getAttentionSet.apply(parseChangeResource(r.getChangeId())).value());
assertThat(getAttentionSetInfo.reason).isEqualTo(manualReason);
assertThat(getAttentionSetInfo.reasonAccount).isNull();
assertThat(getAttentionSetInfo.account).isEqualTo(getAccountInfo(admin.id()));
}
Aggregations