use of com.google.gerrit.server.update.ChangeContext in project gerrit by GerritCodeReview.
the class PrivateChangeIT method markMergedChangePrivate.
private void markMergedChangePrivate(Change.Id changeId) throws Exception {
try (BatchUpdate u = batchUpdateFactory.create(project, identifiedUserFactory.create(admin.id()), TimeUtil.now())) {
u.addOp(changeId, new BatchUpdateOp() {
@Override
public boolean updateChange(ChangeContext ctx) {
ctx.getChange().setPrivate(true);
ChangeUpdate update = ctx.getUpdate(ctx.getChange().currentPatchSetId());
ctx.getChange().setPrivate(true);
ctx.getChange().setLastUpdatedOn(ctx.getWhen());
update.setPrivate(true);
return true;
}
}).execute();
}
assertThat(gApi.changes().id(changeId.get()).get().isPrivate).isTrue();
}
use of com.google.gerrit.server.update.ChangeContext in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method mergedChangeIsNotMerged.
@Test
public void mergedChangeIsNotMerged() throws Exception {
ChangeNotes notes = insertChange();
try (BatchUpdate bu = newUpdate(adminId)) {
bu.addOp(notes.getChangeId(), new BatchUpdateOp() {
@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();
}
notes = reload(notes);
ObjectId tip = getDestRef(notes);
assertProblems(notes, null, problem("Patch set 1 (" + psUtil.current(notes).commitId().name() + ") is not merged into destination ref" + " refs/heads/master (" + tip.name() + "), but change status is MERGED"));
}
use of com.google.gerrit.server.update.ChangeContext 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);
}
Aggregations