Search in sources :

Example 1 with RequestId

use of com.google.gerrit.server.util.RequestId in project gerrit by GerritCodeReview.

the class CommitMessageOutputTest method submitCommitFormat.

@Test
public void submitCommitFormat() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setSubjectForCommit("Submit patch set 1");
    RequestId submissionId = RequestId.forChange(c);
    update.merge(submissionId, ImmutableList.of(submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Code-Review", "NEED", null)), submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Alternative-Code-Review", "NEED", null))));
    update.commit();
    RevCommit commit = parseCommit(update.getResult());
    assertBodyEquals("Submit patch set 1\n" + "\n" + "Patch-set: 1\n" + "Status: merged\n" + "Submission-id: " + submissionId.toStringForStorage() + "\n" + "Submitted-with: NOT_READY\n" + "Submitted-with: OK: Verified: Change Owner <1@gerrit>\n" + "Submitted-with: NEED: Code-Review\n" + "Submitted-with: NOT_READY\n" + "Submitted-with: OK: Verified: Change Owner <1@gerrit>\n" + "Submitted-with: NEED: Alternative-Code-Review\n", commit);
    PersonIdent author = commit.getAuthorIdent();
    assertThat(author.getName()).isEqualTo("Change Owner");
    assertThat(author.getEmailAddress()).isEqualTo("1@gerrit");
    assertThat(author.getWhen()).isEqualTo(new Date(c.getCreatedOn().getTime() + 2000));
    assertThat(author.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT-7:00"));
    PersonIdent committer = commit.getCommitterIdent();
    assertThat(committer.getName()).isEqualTo("Gerrit Server");
    assertThat(committer.getEmailAddress()).isEqualTo("noreply@gerrit.com");
    assertThat(committer.getWhen()).isEqualTo(author.getWhen());
    assertThat(committer.getTimeZone()).isEqualTo(author.getTimeZone());
}
Also used : RequestId(com.google.gerrit.server.util.RequestId) PersonIdent(org.eclipse.jgit.lib.PersonIdent) Change(com.google.gerrit.reviewdb.client.Change) Date(java.util.Date) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 2 with RequestId

use of com.google.gerrit.server.util.RequestId 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 3 with RequestId

use of com.google.gerrit.server.util.RequestId in project gerrit by GerritCodeReview.

the class ChangeNotesTest method submitRecords.

@Test
public void submitRecords() throws Exception {
    Change c = newChange();
    RequestId submissionId = RequestId.forChange(c);
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setSubjectForCommit("Submit patch set 1");
    update.merge(submissionId, ImmutableList.of(submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Code-Review", "NEED", null)), submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Alternative-Code-Review", "NEED", null))));
    update.commit();
    ChangeNotes notes = newNotes(c);
    List<SubmitRecord> recs = notes.getSubmitRecords();
    assertThat(recs).hasSize(2);
    assertThat(recs.get(0)).isEqualTo(submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Code-Review", "NEED", null)));
    assertThat(recs.get(1)).isEqualTo(submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Alternative-Code-Review", "NEED", null)));
    assertThat(notes.getChange().getSubmissionId()).isEqualTo(submissionId.toStringForStorage());
}
Also used : SubmitRecord(com.google.gerrit.common.data.SubmitRecord) RequestId(com.google.gerrit.server.util.RequestId) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 4 with RequestId

use of com.google.gerrit.server.util.RequestId in project gerrit by GerritCodeReview.

the class ChangeNotesTest method latestSubmitRecordsOnly.

@Test
public void latestSubmitRecordsOnly() throws Exception {
    Change c = newChange();
    RequestId submissionId = RequestId.forChange(c);
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setSubjectForCommit("Submit patch set 1");
    update.merge(submissionId, ImmutableList.of(submitRecord("OK", null, submitLabel("Code-Review", "OK", otherUser.getAccountId()))));
    update.commit();
    incrementPatchSet(c);
    update = newUpdate(c, changeOwner);
    update.setSubjectForCommit("Submit patch set 2");
    update.merge(submissionId, ImmutableList.of(submitRecord("OK", null, submitLabel("Code-Review", "OK", changeOwner.getAccountId()))));
    update.commit();
    ChangeNotes notes = newNotes(c);
    assertThat(notes.getSubmitRecords()).containsExactly(submitRecord("OK", null, submitLabel("Code-Review", "OK", changeOwner.getAccountId())));
    assertThat(notes.getChange().getSubmissionId()).isEqualTo(submissionId.toStringForStorage());
}
Also used : RequestId(com.google.gerrit.server.util.RequestId) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 5 with RequestId

use of com.google.gerrit.server.util.RequestId in project gerrit by GerritCodeReview.

the class CommitMessageOutputTest method submitWithErrorMessage.

@Test
public void submitWithErrorMessage() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    update.setSubjectForCommit("Submit patch set 1");
    RequestId submissionId = RequestId.forChange(c);
    update.merge(submissionId, ImmutableList.of(submitRecord("RULE_ERROR", "Problem with patch set:\n1")));
    update.commit();
    assertBodyEquals("Submit patch set 1\n" + "\n" + "Patch-set: 1\n" + "Status: merged\n" + "Submission-id: " + submissionId.toStringForStorage() + "\n" + "Submitted-with: RULE_ERROR Problem with patch set: 1\n", update.getResult());
}
Also used : RequestId(com.google.gerrit.server.util.RequestId) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Aggregations

Change (com.google.gerrit.reviewdb.client.Change)7 RequestId (com.google.gerrit.server.util.RequestId)7 Test (org.junit.Test)6 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Stopwatch (com.google.common.base.Stopwatch)1 Throwables (com.google.common.base.Throwables)1 ImmutableList (com.google.common.collect.ImmutableList)1 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 Nullable (com.google.gerrit.common.Nullable)1 SubmitRecord (com.google.gerrit.common.data.SubmitRecord)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 Description (com.google.gerrit.metrics.Description)1 Units (com.google.gerrit.metrics.Description.Units)1