Search in sources :

Example 76 with Change

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);
}
Also used : Change(com.google.gerrit.entities.Change) PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) Test(org.junit.Test)

Example 77 with Change

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));
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) Instant(java.time.Instant) CommentRange(com.google.gerrit.entities.CommentRange) PatchSet(com.google.gerrit.entities.PatchSet) Change(com.google.gerrit.entities.Change) HumanComment(com.google.gerrit.entities.HumanComment) Test(org.junit.Test)

Example 78 with Change

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);
}
Also used : Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 79 with Change

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());
}
Also used : Change(com.google.gerrit.entities.Change) PatchSetApproval(com.google.gerrit.entities.PatchSetApproval) Test(org.junit.Test)

Example 80 with Change

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());
}
Also used : ChangeMessage(com.google.gerrit.entities.ChangeMessage) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Aggregations

Change (com.google.gerrit.entities.Change)659 Test (org.junit.Test)510 PatchSet (com.google.gerrit.entities.PatchSet)167 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)165 ObjectId (org.eclipse.jgit.lib.ObjectId)113 Repo (com.google.gerrit.testing.InMemoryRepositoryManager.Repo)112 RevCommit (org.eclipse.jgit.revwalk.RevCommit)88 Account (com.google.gerrit.entities.Account)83 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)72 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)66 List (java.util.List)64 ImmutableList (com.google.common.collect.ImmutableList)63 ChangeData (com.google.gerrit.server.query.change.ChangeData)60 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)58 PatchSetApproval (com.google.gerrit.entities.PatchSetApproval)56 Instant (java.time.Instant)54 Project (com.google.gerrit.entities.Project)52 StorageException (com.google.gerrit.exceptions.StorageException)50 Ref (org.eclipse.jgit.lib.Ref)49 HumanComment (com.google.gerrit.entities.HumanComment)46