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;
}
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());
}
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);
}
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);
}
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);
}
Aggregations