use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class MailProcessorIT method parseAndPersistInlineComment.
@Test
public void parseAndPersistInlineComment() throws Exception {
String changeId = createChangeWithReview();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
String ts = MailProcessingUtil.rfcDateformatter.format(ZonedDateTime.ofInstant(gApi.changes().id(changeId).get().updated.toInstant(), ZoneId.of("UTC")));
// Build Message
MailMessage.Builder b = messageBuilderWithDefaultFields();
String txt = newPlaintextBody(getChangeUrl(changeInfo) + "/1", null, "Some Inline Comment", null);
b.textContent(txt + textFooterForChange(changeInfo._number, ts));
mailProcessor.process(b.build());
// Assert messages
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeId).get().messages;
assertThat(messages).hasSize(3);
assertThat(Iterables.getLast(messages).message).isEqualTo("Patch Set 1:\n\n(1 comment)");
assertThat(Iterables.getLast(messages).tag).isEqualTo("mailMessageId=some id");
// Assert comment
List<CommentInfo> comments = gApi.changes().id(changeId).current().commentsAsList();
assertThat(comments).hasSize(3);
assertThat(comments.get(2).message).isEqualTo("Some Inline Comment");
assertThat(comments.get(2).tag).isEqualTo("mailMessageId=some id");
assertThat(comments.get(2).inReplyTo).isEqualTo(comments.get(1).id);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class AbandonRestoreIT method assertChangeMessages.
private void assertChangeMessages(String changeId, List<String> expected) throws Exception {
ChangeInfo c = get(changeId, MESSAGES);
Iterable<ChangeMessageInfo> messages = c.messages;
assertThat(messages).isNotNull();
assertThat(messages).hasSize(expected.size());
List<String> actual = new ArrayList<>();
for (ChangeMessageInfo info : messages) {
actual.add(info.message);
}
assertThat(actual).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class ImpersonationIT method changeMessageCreatedOnBehalfOfHasRealUser.
@Test
public void changeMessageCreatedOnBehalfOfHasRealUser() throws Exception {
allowCodeReviewOnBehalfOf();
PushOneCommit.Result r = createChange();
ReviewInput in = new ReviewInput();
in.onBehalfOf = user.id().toString();
in.message = "Message on behalf of";
in.label("Code-Review", 1);
requestScopeOperations.setApiUser(accountCreator.user2().id());
gApi.changes().id(r.getChangeId()).revision(r.getPatchSetId().getId()).review(in);
ChangeInfo info = gApi.changes().id(r.getChangeId()).get(MESSAGES);
assertThat(info.messages).hasSize(2);
ChangeMessageInfo changeMessageInfo = Iterables.getLast(info.messages);
assertThat(changeMessageInfo.realAuthor).isNotNull();
assertThat(changeMessageInfo.realAuthor._accountId).isEqualTo(accountCreator.user2().id().get());
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class DeleteVoteIT method deleteVote.
private void deleteVote(boolean onRevisionLevel) throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
PushOneCommit.Result r2 = amendChange(r.getChangeId());
requestScopeOperations.setApiUser(user.id());
recommend(r.getChangeId());
sender.clear();
String endPoint = "/changes/" + r.getChangeId() + (onRevisionLevel ? ("/revisions/" + r2.getCommit().getName()) : "") + "/reviewers/" + user.id().toString() + "/votes/Code-Review";
RestResponse response = adminRestSession.delete(endPoint);
response.assertNoContent();
List<FakeEmailSender.Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
FakeEmailSender.Message msg = messages.get(0);
assertThat(msg.rcpt()).containsExactly(user.getNameEmail());
assertThat(msg.body()).contains(admin.fullName() + " has removed a vote from this change.");
assertThat(msg.body()).contains("Removed Code-Review+1 by " + user.fullName() + " <" + user.email() + ">\n");
endPoint = "/changes/" + r.getChangeId() + (onRevisionLevel ? ("/revisions/" + r2.getCommit().getName()) : "") + "/reviewers/" + user.id().toString() + "/votes";
response = adminRestSession.get(endPoint);
response.assertOK();
Map<String, Short> m = newGson().fromJson(response.getReader(), new TypeToken<Map<String, Short>>() {
}.getType());
assertThat(m).containsExactly(LabelId.CODE_REVIEW, Short.valueOf((short) 0));
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
ChangeMessageInfo message = Iterables.getLast(c.messages);
assertThat(message.author._accountId).isEqualTo(admin.id().get());
assertThat(message.message).isEqualTo(String.format("Removed Code-Review+1 by %s\n", AccountTemplateUtil.getAccountTemplate(user.id())));
assertThat(getReviewers(c.reviewers.get(REVIEWER))).containsExactlyElementsIn(ImmutableSet.of(admin.id(), user.id()));
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class HashtagsIT method addAlreadyExistingHashtag.
@Test
public void addAlreadyExistingHashtag() throws Exception {
// Adding a hashtag that already exists on the change returns a sorted list
// of hashtags without duplicates.
PushOneCommit.Result r = createChange();
addHashtags(r, "tag2");
assertThatGet(r).containsExactly("tag2");
assertMessage(r, "Hashtag added: tag2");
ChangeMessageInfo last = getLastMessage(r);
addHashtags(r, "tag2");
assertThatGet(r).containsExactly("tag2");
assertNoNewMessageSince(r, last);
addHashtags(r, "tag1", "tag2");
assertThatGet(r).containsExactly("tag1", "tag2").inOrder();
assertMessage(r, "Hashtag added: tag1");
}
Aggregations