use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.
the class ChangeNotesTest method changeMessageWithMultipleParagraphs.
@Test
public void changeMessageWithMultipleParagraphs() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.setChangeMessage("Testing paragraph 1\n\nTesting paragraph 2\n\nTesting paragraph 3");
update.commit();
PatchSet.Id ps1 = c.currentPatchSetId();
ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = notes.getChangeMessagesByPatchSet();
assertThat(changeMessages).hasSize(1);
ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1));
assertThat(cm1.getMessage()).isEqualTo("Testing paragraph 1\n" + "\n" + "Testing paragraph 2\n" + "\n" + "Testing paragraph 3");
assertThat(cm1.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
}
use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.
the class ChangeNotesTest method changeMessagesMultiplePatchSets.
@Test
public void changeMessagesMultiplePatchSets() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.putReviewer(changeOwner.getAccount().getId(), REVIEWER);
update.setChangeMessage("This is the change message for the first PS.");
update.commit();
PatchSet.Id ps1 = c.currentPatchSetId();
incrementPatchSet(c);
update = newUpdate(c, changeOwner);
update.setChangeMessage("This is the change message for the second PS.");
update.commit();
PatchSet.Id ps2 = c.currentPatchSetId();
ChangeNotes notes = newNotes(c);
ListMultimap<PatchSet.Id, ChangeMessage> changeMessages = notes.getChangeMessagesByPatchSet();
assertThat(changeMessages).hasSize(2);
ChangeMessage cm1 = Iterables.getOnlyElement(changeMessages.get(ps1));
assertThat(cm1.getMessage()).isEqualTo("This is the change message for the first PS.");
assertThat(cm1.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
ChangeMessage cm2 = Iterables.getOnlyElement(changeMessages.get(ps2));
assertThat(cm1.getPatchSetId()).isEqualTo(ps1);
assertThat(cm2.getMessage()).isEqualTo("This is the change message for the second PS.");
assertThat(cm2.getAuthor()).isEqualTo(changeOwner.getAccount().getId());
assertThat(cm2.getPatchSetId()).isEqualTo(ps2);
}
use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffChangeMessagesMixedSourcesAllowsSlop.
@Test
public void diffChangeMessagesMixedSourcesAllowsSlop() throws Exception {
subWindowResolution();
Change c = TestChanges.newChange(project, accountId);
ChangeMessage cm1 = new ChangeMessage(new ChangeMessage.Key(c.getId(), "uuid1"), accountId, TimeUtil.nowTs(), c.currentPatchSetId());
ChangeMessage cm2 = clone(cm1);
cm2.setWrittenOn(TimeUtil.nowTs());
// Both are ReviewDb, exact timestamp match is required.
ChangeBundle b1 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(cm2), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "writtenOn differs for ChangeMessage.Key " + c.getId() + ",uuid1:" + " {2009-09-30 17:00:02.0} != {2009-09-30 17:00:03.0}");
// One NoteDb, slop is allowed.
b1 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), NOTE_DB);
b2 = new ChangeBundle(c, messages(cm2), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
assertNoDiffs(b1, b2);
assertNoDiffs(b2, b1);
// But not too much slop.
superWindowResolution();
ChangeMessage cm3 = clone(cm1);
cm3.setWrittenOn(TimeUtil.nowTs());
b1 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), NOTE_DB);
ChangeBundle b3 = new ChangeBundle(c, messages(cm3), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
int id = c.getId().get();
assertDiffs(b1, b3, "ChangeMessages differ for Change.Id " + id + "\n" + "Only in A:\n " + cm1 + "\n" + "Only in B:\n " + cm3);
assertDiffs(b3, b1, "ChangeMessages differ for Change.Id " + id + "\n" + "Only in A:\n " + cm3 + "\n" + "Only in B:\n " + cm1);
}
use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffChangeMessagesWithDifferentCounts.
@Test
public void diffChangeMessagesWithDifferentCounts() throws Exception {
Change c = TestChanges.newChange(project, accountId);
int id = c.getId().get();
ChangeMessage cm1 = new ChangeMessage(new ChangeMessage.Key(c.getId(), "uuid1"), accountId, TimeUtil.nowTs(), c.currentPatchSetId());
cm1.setMessage("message 1");
ChangeMessage cm2 = new ChangeMessage(new ChangeMessage.Key(c.getId(), "uuid2"), accountId, TimeUtil.nowTs(), c.currentPatchSetId());
cm1.setMessage("message 2");
// Both ReviewDb: Uses same keySet diff as other types.
ChangeBundle b1 = new ChangeBundle(c, messages(cm1, cm2), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "ChangeMessage.Key sets differ: [" + id + ",uuid2] only in A; [] only in B");
// One NoteDb: UUIDs in keys can't be used for comparison, just diff counts.
b1 = new ChangeBundle(c, messages(cm1, cm2), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
b2 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), NOTE_DB);
assertDiffs(b1, b2, "ChangeMessages differ for Change.Id " + id + "\nOnly in A:\n " + cm2);
assertDiffs(b2, b1, "ChangeMessages differ for Change.Id " + id + "\nOnly in B:\n " + cm2);
}
use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffChangeMessagesAllowsNullPatchSetIdFromReviewDb.
@Test
public void diffChangeMessagesAllowsNullPatchSetIdFromReviewDb() throws Exception {
Change c = TestChanges.newChange(project, accountId);
int id = c.getId().get();
ChangeMessage cm1 = new ChangeMessage(new ChangeMessage.Key(c.getId(), "uuid"), accountId, TimeUtil.nowTs(), c.currentPatchSetId());
cm1.setMessage("message 1");
ChangeMessage cm2 = clone(cm1);
cm2.setPatchSetId(null);
ChangeBundle b1 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(cm2), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
// Both are ReviewDb, exact patch set ID match is required.
assertDiffs(b1, b2, "patchset differs for ChangeMessage.Key " + c.getId() + ",uuid:" + " {" + id + ",1} != {null}");
// Null patch set ID on ReviewDb is ignored.
b1 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), NOTE_DB);
b2 = new ChangeBundle(c, messages(cm2), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
assertNoDiffs(b1, b2);
// Null patch set ID on NoteDb is not ignored (but is not realistic).
b1 = new ChangeBundle(c, messages(cm1), latest(c), approvals(), comments(), reviewers(), REVIEW_DB);
b2 = new ChangeBundle(c, messages(cm2), latest(c), approvals(), comments(), reviewers(), NOTE_DB);
assertDiffs(b1, b2, "ChangeMessages differ for Change.Id " + id + "\n" + "Only in A:\n " + cm1 + "\n" + "Only in B:\n " + cm2);
assertDiffs(b2, b1, "ChangeMessages differ for Change.Id " + id + "\n" + "Only in A:\n " + cm2 + "\n" + "Only in B:\n " + cm1);
}
Aggregations