Search in sources :

Example 36 with ChangeMessage

use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.

the class ChangeNotesTest method realUser.

@Test
public void realUser() throws Exception {
    Change c = newChange();
    CurrentUser ownerAsOtherUser = userFactory.runAs(null, otherUserId, changeOwner);
    ChangeUpdate update = newUpdate(c, ownerAsOtherUser);
    update.setChangeMessage("Message on behalf of other user");
    update.commit();
    ChangeMessage msg = Iterables.getLast(newNotes(c).getChangeMessages());
    assertThat(msg.getMessage()).isEqualTo("Message on behalf of other user");
    assertThat(msg.getAuthor()).isEqualTo(otherUserId);
    assertThat(msg.getRealAuthor()).isEqualTo(changeOwner.getAccountId());
}
Also used : CurrentUser(com.google.gerrit.server.CurrentUser) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 37 with ChangeMessage

use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.

the class ChangeNotesTest method changeMessageMultipleInOnePatchSet.

@Test
public void changeMessageMultipleInOnePatchSet() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.putReviewer(changeOwner.getAccount().getId(), REVIEWER);
    update.setChangeMessage("First change message.\n");
    update.commit();
    PatchSet.Id ps1 = c.currentPatchSetId();
    update = newUpdate(c, changeOwner);
    update.putReviewer(changeOwner.getAccount().getId(), REVIEWER);
    update.setChangeMessage("Second change message.\n");
    update.commit();
    ChangeNotes notes = newNotes(c);
    ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = notes.getChangeMessagesByPatchSet();
    assertThat(changeMessages.keySet()).hasSize(1);
    List<ChangeMessage> cm = changeMessages.get(ps1);
    assertThat(cm).hasSize(2);
    assertThat(cm.get(0).getMessage()).isEqualTo("First change message.\n");
    assertThat(cm.get(0).getAuthor()).isEqualTo(changeOwner.getAccount().getId());
    assertThat(cm.get(0).getPatchSetId()).isEqualTo(ps1);
    assertThat(cm.get(1).getMessage()).isEqualTo("Second change message.\n");
    assertThat(cm.get(1).getAuthor()).isEqualTo(changeOwner.getAccount().getId());
    assertThat(cm.get(1).getPatchSetId()).isEqualTo(ps1);
}
Also used : ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) RequestId(com.google.gerrit.server.util.RequestId) GerritServerId(com.google.gerrit.server.config.GerritServerId) ObjectId(org.eclipse.jgit.lib.ObjectId) RevId(com.google.gerrit.reviewdb.client.RevId) Test(org.junit.Test)

Example 38 with ChangeMessage

use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.

the class ChangeNotesTest method updateWithServerIdent.

@Test
public void updateWithServerIdent() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, internalUser);
    update.setChangeMessage("A message.");
    update.commit();
    ChangeMessage msg = Iterables.getLast(newNotes(c).getChangeMessages());
    assertThat(msg.getMessage()).isEqualTo("A message.");
    assertThat(msg.getAuthor()).isNull();
    update = newUpdate(c, internalUser);
    exception.expect(IllegalStateException.class);
    update.putApproval("Code-Review", (short) 1);
}
Also used : ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 39 with ChangeMessage

use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.

the class DeleteReviewerByEmailOp method updateChange.

@Override
public boolean updateChange(ChangeContext ctx) throws OrmException {
    changeId = ctx.getChange().getId();
    PatchSet.Id psId = ctx.getChange().currentPatchSetId();
    String msg = "Removed reviewer " + reviewer;
    changeMessage = new ChangeMessage(new ChangeMessage.Key(changeId, ChangeUtil.messageUuid()), ctx.getAccountId(), ctx.getWhen(), psId);
    changeMessage.setMessage(msg);
    ctx.getUpdate(psId).setChangeMessage(msg);
    ctx.getUpdate(psId).removeReviewerByEmail(reviewer);
    return true;
}
Also used : ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet)

Example 40 with ChangeMessage

use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.

the class ChangeBundle method getLatestTimestamp.

private Timestamp getLatestTimestamp() {
    Ordering<Timestamp> o = Ordering.natural().nullsFirst();
    Timestamp ts = null;
    for (ChangeMessage cm : filterChangeMessages()) {
        ts = o.max(ts, cm.getWrittenOn());
    }
    for (PatchSet ps : getPatchSets()) {
        ts = o.max(ts, ps.getCreatedOn());
    }
    for (PatchSetApproval psa : filterPatchSetApprovals().values()) {
        ts = o.max(ts, psa.getGranted());
    }
    for (PatchLineComment plc : filterPatchLineComments().values()) {
        // Ignore draft comments, as they do not show up in the change meta graph.
        if (plc.getStatus() != PatchLineComment.Status.DRAFT) {
            ts = o.max(ts, plc.getWrittenOn());
        }
    }
    return firstNonNull(ts, change.getLastUpdatedOn());
}
Also used : PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Timestamp(java.sql.Timestamp) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval)

Aggregations

ChangeMessage (com.google.gerrit.reviewdb.client.ChangeMessage)42 Change (com.google.gerrit.reviewdb.client.Change)31 Test (org.junit.Test)25 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)16 ObjectId (org.eclipse.jgit.lib.ObjectId)11 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)9 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)9 RevId (com.google.gerrit.reviewdb.client.RevId)8 GerritServerId (com.google.gerrit.server.config.GerritServerId)7 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)6 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)6 RequestId (com.google.gerrit.server.util.RequestId)6 Account (com.google.gerrit.reviewdb.client.Account)5 Comment (com.google.gerrit.reviewdb.client.Comment)5 ChangeData (com.google.gerrit.server.query.change.ChangeData)5 CommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput)4 PatchLineComment (com.google.gerrit.reviewdb.client.PatchLineComment)4 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)3 Table (com.google.common.collect.Table)2