Search in sources :

Example 6 with ChangeMessage

use of com.google.gerrit.entities.ChangeMessage in project gerrit by GerritCodeReview.

the class ListChangeCommentsTest method newChangeMessage.

/**
 * Create a new change message with an id, message, timestamp and tag
 */
private static ChangeMessage newChangeMessage(String id, String message, String ts, String tag) {
    ChangeMessage.Key key = ChangeMessage.key(Change.id(1), id);
    Instant timestamp = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()).parse("2000-01-01 00:00:" + ts, Instant::from);
    ChangeMessage cm = ChangeMessage.create(key, null, timestamp, null, message, null, tag);
    return cm;
}
Also used : Instant(java.time.Instant) ChangeMessage(com.google.gerrit.entities.ChangeMessage)

Example 7 with ChangeMessage

use of com.google.gerrit.entities.ChangeMessage in project gerrit by GerritCodeReview.

the class ImpersonationIT method voteOnBehalfOf.

@Test
public void voteOnBehalfOf() throws Exception {
    allowCodeReviewOnBehalfOf();
    PushOneCommit.Result r = createChange();
    RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
    ReviewInput in = ReviewInput.recommend();
    in.onBehalfOf = user.id().toString();
    in.message = "Message on behalf of";
    revision.review(in);
    PatchSetApproval psa = Iterables.getOnlyElement(r.getChange().approvals().values());
    assertThat(psa.patchSetId().get()).isEqualTo(1);
    assertThat(psa.label()).isEqualTo("Code-Review");
    assertThat(psa.accountId()).isEqualTo(user.id());
    assertThat(psa.value()).isEqualTo(1);
    assertThat(psa.realAccountId()).isEqualTo(admin.id());
    ChangeData cd = r.getChange();
    ChangeMessage m = Iterables.getLast(cmUtil.byChange(cd.notes()));
    assertThat(m.getMessage()).endsWith(in.message);
    assertThat(m.getAuthor()).isEqualTo(user.id());
    assertThat(m.getRealAuthor()).isEqualTo(admin.id());
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) ChangeMessage(com.google.gerrit.entities.ChangeMessage) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) ChangeData(com.google.gerrit.server.query.change.ChangeData) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 8 with ChangeMessage

use of com.google.gerrit.entities.ChangeMessage in project gerrit by GerritCodeReview.

the class ChangeMessageProtoConverterTest method allValuesConvertedToProto.

@Test
public void allValuesConvertedToProto() {
    ChangeMessage changeMessage = ChangeMessage.create(ChangeMessage.key(Change.id(543), "change-message-21"), Account.id(63), Instant.ofEpochMilli(9876543), PatchSet.id(Change.id(34), 13), "This is a change message.", Account.id(10003), "An arbitrary tag.");
    Entities.ChangeMessage proto = changeMessageProtoConverter.toProto(changeMessage);
    Entities.ChangeMessage expectedProto = Entities.ChangeMessage.newBuilder().setKey(Entities.ChangeMessage_Key.newBuilder().setChangeId(Entities.Change_Id.newBuilder().setId(543)).setUuid("change-message-21")).setAuthorId(Entities.Account_Id.newBuilder().setId(63)).setWrittenOn(9876543).setMessage("This is a change message.").setPatchset(Entities.PatchSet_Id.newBuilder().setChangeId(Entities.Change_Id.newBuilder().setId(34)).setId(13)).setTag("An arbitrary tag.").setRealAuthor(Entities.Account_Id.newBuilder().setId(10003)).build();
    assertThat(proto).isEqualTo(expectedProto);
}
Also used : ChangeMessage(com.google.gerrit.entities.ChangeMessage) Entities(com.google.gerrit.proto.Entities) Test(org.junit.Test)

Example 9 with ChangeMessage

use of com.google.gerrit.entities.ChangeMessage in project gerrit by GerritCodeReview.

the class ChangeMessageProtoConverterTest method messageTemplateConvertedToProtoAndParsedBack.

@Test
public void messageTemplateConvertedToProtoAndParsedBack() {
    ChangeMessage changeMessage = ChangeMessage.create(ChangeMessage.key(Change.id(543), "change-message-21"), Account.id(63), Instant.ofEpochMilli(9876543), PatchSet.id(Change.id(34), 13), String.format("This is a change message by %s and includes %s ", AccountTemplateUtil.getAccountTemplate(Account.id(10001)), AccountTemplateUtil.getAccountTemplate(Account.id(10002))), Account.id(10003), "An arbitrary tag.");
    ChangeMessage convertedChangeMessage = changeMessageProtoConverter.fromProto(changeMessageProtoConverter.toProto(changeMessage));
    assertThat(convertedChangeMessage).isEqualTo(changeMessage);
}
Also used : ChangeMessage(com.google.gerrit.entities.ChangeMessage) Test(org.junit.Test)

Example 10 with ChangeMessage

use of com.google.gerrit.entities.ChangeMessage in project gerrit by GerritCodeReview.

the class ChangeMessageProtoConverterTest method mainValuesConvertedToProtoAndBackAgain.

@Test
public void mainValuesConvertedToProtoAndBackAgain() {
    ChangeMessage changeMessage = ChangeMessage.create(ChangeMessage.key(Change.id(543), "change-message-21"), Account.id(63), Instant.ofEpochMilli(9876543), PatchSet.id(Change.id(34), 13));
    ChangeMessage convertedChangeMessage = changeMessageProtoConverter.fromProto(changeMessageProtoConverter.toProto(changeMessage));
    assertThat(convertedChangeMessage).isEqualTo(changeMessage);
}
Also used : ChangeMessage(com.google.gerrit.entities.ChangeMessage) Test(org.junit.Test)

Aggregations

ChangeMessage (com.google.gerrit.entities.ChangeMessage)31 Test (org.junit.Test)23 Change (com.google.gerrit.entities.Change)13 PatchSetApproval (com.google.gerrit.entities.PatchSetApproval)6 List (java.util.List)5 Account (com.google.gerrit.entities.Account)4 LabelId (com.google.gerrit.entities.LabelId)4 Entities (com.google.gerrit.proto.Entities)4 CurrentUser (com.google.gerrit.server.CurrentUser)4 Inject (com.google.inject.Inject)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 AttentionSetUpdate (com.google.gerrit.entities.AttentionSetUpdate)3 Operation (com.google.gerrit.entities.AttentionSetUpdate.Operation)3 CODE_REVIEW (com.google.gerrit.entities.LabelId.CODE_REVIEW)3 VERIFIED (com.google.gerrit.entities.LabelId.VERIFIED)3 RefNames (com.google.gerrit.entities.RefNames)3 SubmitRecord (com.google.gerrit.entities.SubmitRecord)3