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());
}
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();
}
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());
}
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());
}
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());
}
Aggregations