Search in sources :

Example 26 with ChangeMessageInfo

use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.

the class MailProcessorIT method parseAndPersistFileComment.

@Test
public void parseAndPersistFileComment() throws Exception {
    String changeId = createChangeWithReview();
    ChangeInfo changeInfo = gApi.changes().id(changeId).get();
    List<CommentInfo> comments = gApi.changes().id(changeId).current().commentsAsList();
    String ts = MailUtil.rfcDateformatter.format(ZonedDateTime.ofInstant(comments.get(0).updated.toInstant(), ZoneId.of("UTC")));
    // Build Message
    MailMessage.Builder b = messageBuilderWithDefaultFields();
    String txt = newPlaintextBody(canonicalWebUrl.get() + "#/c/" + changeInfo._number + "/1", null, null, "Some Comment on File 1", null);
    b.textContent(txt + textFooterForChange(changeId, 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
    comments = gApi.changes().id(changeId).current().commentsAsList();
    assertThat(comments).hasSize(3);
    assertThat(comments.get(0).message).isEqualTo("Some Comment on File 1");
    assertThat(comments.get(0).inReplyTo).isNull();
    assertThat(comments.get(0).tag).isEqualTo("mailMessageId=some id");
    assertThat(comments.get(0).path).isEqualTo("gerrit-server/test.txt");
}
Also used : MailMessage(com.google.gerrit.server.mail.receive.MailMessage) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) Test(org.junit.Test)

Example 27 with ChangeMessageInfo

use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.

the class ListMailFilterIT method listFilterWhitelistDoesNotFilterListedUser.

@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "WHITELIST")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+ser@example\\.com", "a@b\\.com" })
public void listFilterWhitelistDoesNotFilterListedUser() throws Exception {
    ChangeInfo changeInfo = createChangeAndReplyByEmail();
    // Check that the comments from the email have been persisted
    Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
    assertThat(messages).hasSize(3);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test)

Example 28 with ChangeMessageInfo

use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.

the class ListMailFilterIT method listFilterBlacklistDoesNotFilterNotListedUser.

@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "BLACKLIST")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+@gerritcodereview\\.com", "a@b\\.com" })
public void listFilterBlacklistDoesNotFilterNotListedUser() throws Exception {
    ChangeInfo changeInfo = createChangeAndReplyByEmail();
    // Check that the comments from the email have been persisted
    Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
    assertThat(messages).hasSize(3);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test)

Example 29 with ChangeMessageInfo

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);
    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);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ArrayList(java.util.ArrayList) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo)

Example 30 with ChangeMessageInfo

use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method byComment.

@Test
public void byComment() throws Exception {
    TestRepository<Repo> repo = createProject("repo");
    ChangeInserter ins = newChange(repo);
    Change change = insert(repo, ins);
    ReviewInput input = new ReviewInput();
    input.message = "toplevel";
    ReviewInput.CommentInput commentInput = new ReviewInput.CommentInput();
    commentInput.line = 1;
    commentInput.message = "inline";
    input.comments = ImmutableMap.<String, List<ReviewInput.CommentInput>>of(Patch.COMMIT_MSG, ImmutableList.<ReviewInput.CommentInput>of(commentInput));
    gApi.changes().id(change.getId().get()).current().review(input);
    Map<String, List<CommentInfo>> comments = gApi.changes().id(change.getId().get()).current().comments();
    assertThat(comments).hasSize(1);
    CommentInfo comment = Iterables.getOnlyElement(comments.get(Patch.COMMIT_MSG));
    assertThat(comment.message).isEqualTo(commentInput.message);
    ChangeMessageInfo lastMsg = Iterables.getLast(gApi.changes().id(change.getId().get()).get().messages, null);
    assertThat(lastMsg.message).isEqualTo("Patch Set 1:\n\n(1 comment)\n\n" + input.message);
    assertQuery("comment:foo");
    assertQuery("comment:toplevel", change);
    assertQuery("comment:inline", change);
}
Also used : Repo(com.google.gerrit.testutil.InMemoryRepositoryManager.Repo) RobotCommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput) ChangeInserter(com.google.gerrit.server.change.ChangeInserter) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) Change(com.google.gerrit.reviewdb.client.Change) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Test(org.junit.Test)

Aggregations

ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)31 Test (org.junit.Test)26 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)21 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)17 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)14 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)6 GerritConfig (com.google.gerrit.acceptance.GerritConfig)5 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)5 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)4 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)4 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)3 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)3 MailMessage (com.google.gerrit.server.mail.receive.MailMessage)3 ArrayList (java.util.ArrayList)3 RestResponse (com.google.gerrit.acceptance.RestResponse)2 FakeEmailSender (com.google.gerrit.testutil.FakeEmailSender)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 ImmutableList (com.google.common.collect.ImmutableList)1 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)1 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)1