use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method emptyApproval_uuidGenerated.
@Test
public void emptyApproval_uuidGenerated() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) -1);
update.commit();
ChangeNotes notes = newNotes(c);
PatchSetApproval psa = Iterables.getOnlyElement(notes.getApprovals().get(c.currentPatchSetId()));
assertThat(psa.accountId()).isEqualTo(changeOwner.getAccountId());
assertThat(psa.label()).isEqualTo(LabelId.CODE_REVIEW);
assertThat(psa.value()).isEqualTo((short) -1);
assertParsedUuid(psa);
update = newUpdate(c, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) 0);
update.commit();
notes = newNotes(c);
PatchSetApproval emptyPsa = Iterables.getOnlyElement(notes.getApprovals().get(psa.patchSetId()));
assertThat(emptyPsa.key()).isEqualTo(psa.key());
assertThat(emptyPsa.value()).isEqualTo((short) 0);
assertThat(emptyPsa.label()).isEqualTo(psa.label());
assertParsedUuid(emptyPsa);
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method patchLineCommentNotesFormatMultiplePatchSetsSameCommitId.
@Test
public void patchLineCommentNotesFormatMultiplePatchSetsSameCommitId() throws Exception {
Change c = newChange();
PatchSet.Id psId1 = c.currentPatchSetId();
incrementPatchSet(c);
PatchSet.Id psId2 = c.currentPatchSetId();
String uuid1 = "uuid1";
String uuid2 = "uuid2";
String uuid3 = "uuid3";
String message1 = "comment 1";
String message2 = "comment 2";
String message3 = "comment 3";
CommentRange range1 = new CommentRange(1, 1, 2, 1);
CommentRange range2 = new CommentRange(2, 1, 3, 1);
Instant time = TimeUtil.now();
ObjectId commitId = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
HumanComment comment1 = newComment(psId1, "file1", uuid1, range1, range1.getEndLine(), otherUser, null, time, message1, (short) 0, commitId, false);
HumanComment comment2 = newComment(psId1, "file1", uuid2, range2, range2.getEndLine(), otherUser, null, time, message2, (short) 0, commitId, false);
HumanComment comment3 = newComment(psId2, "file1", uuid3, range1, range1.getEndLine(), otherUser, null, time, message3, (short) 0, commitId, false);
ChangeUpdate update = newUpdate(c, otherUser);
update.setPatchSetId(psId2);
update.putComment(HumanComment.Status.PUBLISHED, comment3);
update.putComment(HumanComment.Status.PUBLISHED, comment2);
update.putComment(HumanComment.Status.PUBLISHED, comment1);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getHumanComments()).isEqualTo(ImmutableListMultimap.of(commitId, comment1, commitId, comment2, commitId, comment3));
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method pastAssigneesChangeNotes.
@Test
public void pastAssigneesChangeNotes() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.setAssignee(otherUserId);
update.commit();
update = newUpdate(c, changeOwner);
update.setAssignee(changeOwner.getAccountId());
update.commit();
update = newUpdate(c, changeOwner);
update.setAssignee(otherUserId);
update.commit();
update = newUpdate(c, changeOwner);
update.removeAssignee();
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getPastAssignees()).hasSize(2);
}
use of com.google.gerrit.entities.Change in project gerrit by GerritCodeReview.
the class ChangeNotesTest method approvalUUID_differentChanges.
@Test
public void approvalUUID_differentChanges() throws Exception {
Change c1 = newChange();
ChangeUpdate update1 = newUpdate(c1, changeOwner);
update1.putApproval(LabelId.CODE_REVIEW, (short) +2);
update1.commit();
Change c2 = newChange();
ChangeUpdate update = newUpdate(c2, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) +2);
update.commit();
ChangeNotes notes1 = newNotes(c1);
PatchSetApproval psa1 = Iterables.getOnlyElement(notes1.getApprovals().get(c1.currentPatchSetId()));
ChangeNotes notes2 = newNotes(c2);
PatchSetApproval psa2 = Iterables.getOnlyElement(notes2.getApprovals().get(c2.currentPatchSetId()));
assertThat(psa1.label()).isEqualTo(psa2.label());
assertThat(psa1.accountId()).isEqualTo(psa2.accountId());
assertThat(psa1.value()).isEqualTo(psa2.value());
// UUID is global: different across changes.
assertThat(psa1.uuid()).isNotEqualTo(psa2.uuid());
}
use of com.google.gerrit.entities.Change 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();
ChangeNotes notes = newNotes(c);
ChangeMessage cm1 = Iterables.getOnlyElement(notes.getChangeMessages());
assertThat(cm1.getMessage()).isEqualTo("Testing paragraph 1\n" + "\n" + "Testing paragraph 2\n" + "\n" + "Testing paragraph 3");
assertThat(cm1.getAuthor()).isEqualTo(changeOwner.getAccount().id());
}
Aggregations