use of com.google.gerrit.entities.SubmissionId in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method mergeChange.
private ChangeNotes mergeChange(ChangeNotes notes) throws Exception {
ObjectId oldId = getDestRef(notes);
ObjectId newId = psUtil.current(notes).commitId();
String dest = notes.getChange().getDest().branch();
try (BatchUpdate bu = newUpdate(adminId)) {
bu.addOp(notes.getChangeId(), new BatchUpdateOp() {
@Override
public void updateRepo(RepoContext ctx) throws IOException {
ctx.addRefUpdate(oldId, newId, dest);
}
@Override
public boolean updateChange(ChangeContext ctx) {
ctx.getChange().setStatus(Change.Status.MERGED);
ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatusToMerged(new SubmissionId(ctx.getChange()));
return true;
}
});
bu.execute();
}
return reload(notes);
}
use of com.google.gerrit.entities.SubmissionId in project gerrit by GerritCodeReview.
the class OpenRepoTest method allowExceedingLimitWhenChangeIsSubmitted.
@Test
public void allowExceedingLimitWhenChangeIsSubmitted() throws Exception {
try (OpenRepo openRepo = openRepo()) {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.merge(new SubmissionId(c), ImmutableList.of(submitRecord("NOT_READY", null, submitLabel("Verified", "OK", changeOwner.getAccountId()), submitLabel("Alternative-Code-Review", "NEED", null))));
ListMultimap<String, ChangeUpdate> changeUpdates = new ImmutableListMultimap.Builder<String, ChangeUpdate>().put("one", update).build();
openRepo.addUpdates(changeUpdates, NO_UPDATES_AT_ALL, MAX_PATCH_SETS);
assertThat(fakeChainedReceiveCommands.commands.size()).isEqualTo(1);
}
}
use of com.google.gerrit.entities.SubmissionId 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");
SubmissionId submissionId = new SubmissionId(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.toString() + "\n" + "Submitted-with: RULE_ERROR Problem with patch set: 1\n", update.getResult());
}
use of com.google.gerrit.entities.SubmissionId in project gerrit by GerritCodeReview.
the class ChangeNotesTest method copiedApprovalsPostSubmit.
@Test
public void copiedApprovalsPostSubmit() throws Exception {
Change c = newChange();
SubmissionId submissionId = new SubmissionId(c);
ChangeUpdate update = newUpdate(c, changeOwner);
update.putCopiedApproval(PatchSetApproval.builder().key(PatchSetApproval.key(c.currentPatchSetId(), changeOwner.getAccountId(), LabelId.create(LabelId.CODE_REVIEW))).value(1).copied(true).granted(TimeUtil.now()).build());
update.putCopiedApproval(PatchSetApproval.builder().key(PatchSetApproval.key(c.currentPatchSetId(), changeOwner.getAccountId(), LabelId.create(LabelId.VERIFIED))).value(1).copied(true).granted(TimeUtil.now()).build());
update.commit();
update = newUpdate(c, changeOwner);
update.merge(submissionId, ImmutableList.of(submitRecord("NOT_READY", null, submitLabel(LabelId.VERIFIED, "OK", changeOwner.getAccountId()), submitLabel(LabelId.CODE_REVIEW, "NEED", null))));
update.commit();
update = newUpdate(c, changeOwner);
update.putCopiedApproval(PatchSetApproval.builder().key(PatchSetApproval.key(c.currentPatchSetId(), changeOwner.getAccountId(), LabelId.create(LabelId.CODE_REVIEW))).value(2).copied(true).granted(TimeUtil.now()).build());
update.commit();
ChangeNotes notes = newNotes(c);
List<PatchSetApproval> approvals = Lists.newArrayList(notes.getApprovalsWithCopied().values());
assertThat(approvals).hasSize(2);
assertThat(approvals.get(0).label()).isEqualTo(LabelId.VERIFIED);
assertThat(approvals.get(0).value()).isEqualTo((short) 1);
assertThat(approvals.get(0).postSubmit()).isFalse();
assertThat(approvals.get(1).label()).isEqualTo(LabelId.CODE_REVIEW);
assertThat(approvals.get(1).value()).isEqualTo((short) 2);
assertThat(approvals.get(1).postSubmit()).isTrue();
}
use of com.google.gerrit.entities.SubmissionId in project gerrit by GerritCodeReview.
the class ChangeNotesTest method mergedOnSetWhenSubmitted.
@Test
public void mergedOnSetWhenSubmitted() 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());
// Next update does not change mergedOn date.
update = newUpdate(c, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) 1);
update.commit();
notes = newNotes(c);
assertThat(notes.getMergedOn().get()).isEqualTo(mergedOn);
assertThat(notes.getMergedOn().get()).isLessThan(notes.getChange().getLastUpdatedOn());
}
Aggregations