Search in sources :

Example 16 with ChangeMessageInfo

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

the class AbstractPushForReview method pushForMasterWithMessage.

@Test
public void pushForMasterWithMessage() throws Exception {
    PushOneCommit.Result r = pushTo("refs/for/master/%m=my_test_message");
    r.assertOkStatus();
    r.assertChange(Change.Status.NEW, null);
    ChangeInfo ci = get(r.getChangeId());
    Collection<ChangeMessageInfo> changeMessages = ci.messages;
    assertThat(changeMessages).hasSize(1);
    for (ChangeMessageInfo cm : changeMessages) {
        assertThat(cm.message).isEqualTo("Uploaded patch set 1.\nmy test message");
    }
    Collection<RevisionInfo> revisions = ci.revisions.values();
    assertThat(revisions).hasSize(1);
    for (RevisionInfo ri : revisions) {
        assertThat(ri.description).isEqualTo("my test message");
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 17 with ChangeMessageInfo

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);
    setApiUser(accounts.user2());
    gApi.changes().id(r.getChangeId()).revision(r.getPatchSetId().getId()).review(in);
    ChangeInfo info = gApi.changes().id(r.getChangeId()).get(EnumSet.of(ListChangesOption.MESSAGES));
    assertThat(info.messages).hasSize(2);
    ChangeMessageInfo changeMessageInfo = Iterables.getLast(info.messages);
    assertThat(changeMessageInfo.realAuthor).isNotNull();
    assertThat(changeMessageInfo.realAuthor._accountId).isEqualTo(accounts.user2().id.get());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) 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 18 with ChangeMessageInfo

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());
    setApiUser(user);
    recommend(r.getChangeId());
    sender.clear();
    String endPoint = "/changes/" + r.getChangeId() + (onRevisionLevel ? ("/revisions/" + r2.getCommit().getName()) : "") + "/reviewers/" + user.getId().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.emailAddress);
    assertThat(msg.body()).contains(admin.fullName + " has removed a vote on this change.\n");
    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.getId().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("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.getId().get());
    assertThat(message.message).isEqualTo("Removed Code-Review+1 by User <user@example.com>\n");
    assertThat(getReviewers(c.reviewers.get(REVIEWER))).containsExactlyElementsIn(ImmutableSet.of(admin.getId(), user.getId()));
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) FakeEmailSender(com.google.gerrit.testutil.FakeEmailSender) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) TypeToken(com.google.gson.reflect.TypeToken)

Example 19 with ChangeMessageInfo

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

the class ChangeMessagesIT method messagesReturnedInChronologicalOrder.

@Test
public void messagesReturnedInChronologicalOrder() throws Exception {
    String changeId = createChange().getChangeId();
    String firstMessage = "Some nits need to be fixed.";
    postMessage(changeId, firstMessage);
    String secondMessage = "I like this feature.";
    postMessage(changeId, secondMessage);
    ChangeInfo c = get(changeId);
    assertThat(c.messages).isNotNull();
    assertThat(c.messages).hasSize(3);
    Iterator<ChangeMessageInfo> it = c.messages.iterator();
    assertThat(it.next().message).isEqualTo("Uploaded patch set 1.");
    assertMessage(firstMessage, it.next().message);
    assertMessage(secondMessage, it.next().message);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 20 with ChangeMessageInfo

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

the class HashtagsIT method getLastMessage.

private ChangeMessageInfo getLastMessage(PushOneCommit.Result r) throws Exception {
    ChangeMessageInfo lastMessage = Iterables.getLast(gApi.changes().id(r.getChange().getId().get()).get().messages, null);
    assertThat(lastMessage).named(lastMessage.message).isNotNull();
    return lastMessage;
}
Also used : ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo)

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