Search in sources :

Example 86 with Change

use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.

the class ChangeNotesTest method subjectLeadingWhitespaceChangeNotes.

@Test
public void subjectLeadingWhitespaceChangeNotes() throws Exception {
    Change c = TestChanges.newChange(project, changeOwner.getAccountId());
    String trimmedSubj = c.getSubject();
    c.setCurrentPatchSet(c.currentPatchSetId(), "  " + trimmedSubj, c.getOriginalSubject());
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setChangeId(c.getKey().get());
    update.setBranch(c.getDest().get());
    update.commit();
    ChangeNotes notes = newNotes(c);
    assertThat(notes.getChange().getSubject()).isEqualTo(trimmedSubj);
    String tabSubj = "\t\t" + trimmedSubj;
    c = TestChanges.newChange(project, changeOwner.getAccountId());
    c.setCurrentPatchSet(c.currentPatchSetId(), tabSubj, c.getOriginalSubject());
    update = newUpdate(c, changeOwner);
    update.setChangeId(c.getKey().get());
    update.setBranch(c.getDest().get());
    update.commit();
    notes = newNotes(c);
    assertThat(notes.getChange().getSubject()).isEqualTo(tabSubj);
}
Also used : Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 87 with Change

use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.

the class ChangeNotesTest method putAndRemoveReviewerByEmail.

@Test
public void putAndRemoveReviewerByEmail() throws Exception {
    Address adr = new Address("Foo Bar", "foo.bar@gerritcodereview.com");
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.putReviewerByEmail(adr, ReviewerStateInternal.REVIEWER);
    update.commit();
    update = newUpdate(c, changeOwner);
    update.removeReviewerByEmail(adr);
    update.commit();
    ChangeNotes notes = newNotes(c);
    assertThat(notes.getReviewersByEmail().all()).isEmpty();
}
Also used : Address(com.google.gerrit.server.mail.Address) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 88 with Change

use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.

the class ChangeNotesTest method approvalsPostSubmit.

@Test
public void approvalsPostSubmit() throws Exception {
    Change c = newChange();
    RequestId submissionId = RequestId.forChange(c);
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.putApproval("Code-Review", (short) 1);
    update.putApproval("Verified", (short) 1);
    update.commit();
    update = newUpdate(c, changeOwner);
    update.merge(submissionId, ImmutableList.of(submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Code-Review", "NEED", null))));
    update.commit();
    update = newUpdate(c, changeOwner);
    update.putApproval("Code-Review", (short) 2);
    update.commit();
    ChangeNotes notes = newNotes(c);
    List<PatchSetApproval> approvals = Lists.newArrayList(notes.getApprovals().values());
    assertThat(approvals).hasSize(2);
    assertThat(approvals.get(0).getLabel()).isEqualTo("Verified");
    assertThat(approvals.get(0).getValue()).isEqualTo((short) 1);
    assertThat(approvals.get(0).isPostSubmit()).isFalse();
    assertThat(approvals.get(1).getLabel()).isEqualTo("Code-Review");
    assertThat(approvals.get(1).getValue()).isEqualTo((short) 2);
    assertThat(approvals.get(1).isPostSubmit()).isTrue();
}
Also used : RequestId(com.google.gerrit.server.util.RequestId) Change(com.google.gerrit.reviewdb.client.Change) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) Test(org.junit.Test)

Example 89 with Change

use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.

the class ChangeNotesTest method privateSetPrivateMultipleTimes.

@Test
public void privateSetPrivateMultipleTimes() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setPrivate(true);
    update.commit();
    update = newUpdate(c, changeOwner);
    update.setPrivate(false);
    update.commit();
    ChangeNotes notes = newNotes(c);
    assertThat(notes.isPrivate()).isFalse();
}
Also used : Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 90 with Change

use of com.google.gerrit.reviewdb.client.Change in project gerrit by GerritCodeReview.

the class ChangeNotesTest method patchSetStates.

@Test
public void patchSetStates() throws Exception {
    Change c = newChange();
    PatchSet.Id psId1 = c.currentPatchSetId();
    incrementCurrentPatchSetFieldOnly(c);
    PatchSet.Id psId2 = c.currentPatchSetId();
    RevCommit commit = tr.commit().message("PS2").create();
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setCommit(rw, commit);
    update.setPatchSetState(PatchSetState.DRAFT);
    update.putApproval("Code-Review", (short) 1);
    update.setChangeMessage("This is a message");
    update.putComment(Status.PUBLISHED, newComment(c.currentPatchSetId(), "a.txt", "uuid1", new CommentRange(1, 2, 3, 4), 1, changeOwner, null, TimeUtil.nowTs(), "Comment", (short) 1, commit.name(), false));
    update.commit();
    ChangeNotes notes = newNotes(c);
    assertThat(notes.getPatchSets().get(psId2).isDraft()).isTrue();
    assertThat(notes.getPatchSets().keySet()).containsExactly(psId1, psId2);
    assertThat(notes.getApprovals()).isNotEmpty();
    assertThat(notes.getChangeMessagesByPatchSet()).isNotEmpty();
    assertThat(notes.getChangeMessages()).isNotEmpty();
    assertThat(notes.getComments()).isNotEmpty();
    // publish ps2
    update = newUpdate(c, changeOwner);
    update.setPatchSetState(PatchSetState.PUBLISHED);
    update.commit();
    notes = newNotes(c);
    assertThat(notes.getPatchSets().get(psId2).isDraft()).isFalse();
    // delete ps2
    update = newUpdate(c, changeOwner);
    update.setPatchSetState(PatchSetState.DELETED);
    update.commit();
    notes = newNotes(c);
    assertThat(notes.getPatchSets().keySet()).containsExactly(psId1);
    assertThat(notes.getApprovals()).isEmpty();
    assertThat(notes.getChangeMessagesByPatchSet()).isEmpty();
    assertThat(notes.getChangeMessages()).isEmpty();
    assertThat(notes.getComments()).isEmpty();
}
Also used : CommentRange(com.google.gerrit.reviewdb.client.CommentRange) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

Change (com.google.gerrit.reviewdb.client.Change)390 Test (org.junit.Test)254 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)103 Repo (com.google.gerrit.testutil.InMemoryRepositoryManager.Repo)65 Timestamp (java.sql.Timestamp)60 ObjectId (org.eclipse.jgit.lib.ObjectId)55 Account (com.google.gerrit.reviewdb.client.Account)52 RevCommit (org.eclipse.jgit.revwalk.RevCommit)50 OrmException (com.google.gwtorm.server.OrmException)46 RevId (com.google.gerrit.reviewdb.client.RevId)45 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)36 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)35 Comment (com.google.gerrit.reviewdb.client.Comment)34 Project (com.google.gerrit.reviewdb.client.Project)34 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)34 Repository (org.eclipse.jgit.lib.Repository)34 ChangeMessage (com.google.gerrit.reviewdb.client.ChangeMessage)30 CommentRange (com.google.gerrit.reviewdb.client.CommentRange)30 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)29 RevWalk (org.eclipse.jgit.revwalk.RevWalk)29