use of com.google.gerrit.entities.SubmissionId in project gerrit by GerritCodeReview.
the class ChangeNotesTest method approvalsDuringSubmit.
@Test
public void approvalsDuringSubmit() throws Exception {
Change c = newChange();
SubmissionId submissionId = new SubmissionId(c);
ChangeUpdate update = newUpdate(c, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) 1);
update.putApproval(LabelId.VERIFIED, (short) 1);
update.commit();
Account.Id ownerId = changeOwner.getAccountId();
Account.Id otherId = otherUser.getAccountId();
update = newUpdate(c, otherUser);
update.merge(submissionId, ImmutableList.of(submitRecord("NOT_READY", null, submitLabel(LabelId.VERIFIED, "OK", ownerId), submitLabel(LabelId.CODE_REVIEW, "NEED", null))));
update.putApproval("Other-Label", (short) 1);
update.putApprovalFor(ownerId, LabelId.CODE_REVIEW, (short) 2);
update.commit();
update = newUpdate(c, otherUser);
update.putApproval("Other-Label", (short) 2);
update.commit();
ChangeNotes notes = newNotes(c);
List<PatchSetApproval> approvals = Lists.newArrayList(notes.getApprovals().values());
assertThat(approvals).hasSize(3);
assertThat(approvals.get(0).accountId()).isEqualTo(ownerId);
assertThat(approvals.get(0).label()).isEqualTo(LabelId.VERIFIED);
assertThat(approvals.get(0).value()).isEqualTo(1);
assertThat(approvals.get(0).postSubmit()).isFalse();
assertParsedUuid(approvals.get(0));
assertThat(approvals.get(1).accountId()).isEqualTo(ownerId);
assertThat(approvals.get(1).label()).isEqualTo(LabelId.CODE_REVIEW);
assertThat(approvals.get(1).value()).isEqualTo(2);
// During submit.
assertThat(approvals.get(1).postSubmit()).isFalse();
assertParsedUuid(approvals.get(1));
assertThat(approvals.get(2).accountId()).isEqualTo(otherId);
assertThat(approvals.get(2).label()).isEqualTo("Other-Label");
assertThat(approvals.get(2).value()).isEqualTo(2);
assertThat(approvals.get(2).postSubmit()).isTrue();
assertParsedUuid(approvals.get(2));
}
use of com.google.gerrit.entities.SubmissionId in project gerrit by GerritCodeReview.
the class ChangeNotesTest method latestSubmitRecordsOnly.
@Test
public void latestSubmitRecordsOnly() throws Exception {
Change c = newChange();
SubmissionId submissionId = new SubmissionId(c);
ChangeUpdate update = newUpdate(c, changeOwner);
update.setSubjectForCommit("Submit patch set 1");
update.merge(submissionId, ImmutableList.of(submitRecord("OK", null, submitLabel(LabelId.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(LabelId.CODE_REVIEW, "OK", changeOwner.getAccountId()))));
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getSubmitRecords()).containsExactly(submitRecord("OK", null, submitLabel(LabelId.CODE_REVIEW, "OK", changeOwner.getAccountId())));
assertThat(notes.getChange().getSubmissionId()).isEqualTo(submissionId.toString());
}
use of com.google.gerrit.entities.SubmissionId in project gerrit by GerritCodeReview.
the class ChangeNotesTest method latestMergedOn.
@Test
public void latestMergedOn() throws Exception {
Change c = newChange();
SubmissionId submissionId = new SubmissionId(c);
ChangeUpdate update = newUpdate(c, changeOwner);
update.setSubjectForCommit("Update patch set 1");
update.merge(submissionId, ImmutableList.of(submitRecord("OK", null, submitLabel(LabelId.CODE_REVIEW, "OK", otherUser.getAccountId()))));
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getMergedOn()).isPresent();
Instant mergedOn = notes.getMergedOn().get();
assertThat(mergedOn).isEqualTo(notes.getChange().getLastUpdatedOn());
incrementPatchSet(c);
update = newUpdate(c, changeOwner);
update.setSubjectForCommit("Update patch set 2");
update.merge(submissionId, ImmutableList.of(submitRecord("OK", null, submitLabel(LabelId.CODE_REVIEW, "OK", changeOwner.getAccountId()))));
update.commit();
notes = newNotes(c);
assertThat(notes.getMergedOn().get()).isGreaterThan(mergedOn);
assertThat(notes.getMergedOn().get()).isEqualTo(notes.getChange().getLastUpdatedOn());
}
Aggregations