use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method patchSetObjectAndRefMissingWithFix.
@Test
public void patchSetObjectAndRefMissingWithFix() throws Exception {
String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
ChangeControl ctl = insertChange();
PatchSet ps = insertMissingPatchSet(ctl, rev);
ctl = reload(ctl);
String refName = ps.getId().toRefName();
assertProblems(ctl, new FixInput(), problem("Ref missing: " + refName), problem("Object missing: patch set 2: " + rev));
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method patchSetMultipleObjectsMissingWithDeletingPatchSets.
@Test
public void patchSetMultipleObjectsMissingWithDeletingPatchSets() throws Exception {
ChangeControl ctl = insertChange();
PatchSet ps1 = psUtil.current(db, ctl.getNotes());
String rev2 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
PatchSet ps2 = insertMissingPatchSet(ctl, rev2);
ctl = incrementPatchSet(reload(ctl));
PatchSet ps3 = psUtil.current(db, ctl.getNotes());
String rev4 = "c0ffeeeec0ffeeeec0ffeeeec0ffeeeec0ffeeee";
PatchSet ps4 = insertMissingPatchSet(ctl, rev4);
ctl = reload(ctl);
FixInput fix = new FixInput();
fix.deletePatchSetIfCommitMissing = true;
assertProblems(ctl, fix, problem("Ref missing: " + ps2.getId().toRefName()), problem("Object missing: patch set 2: " + rev2, FIXED, "Deleted patch set"), problem("Ref missing: " + ps4.getId().toRefName()), problem("Object missing: patch set 4: " + rev4, FIXED, "Deleted patch set"));
ctl = reload(ctl);
assertThat(ctl.getChange().currentPatchSetId().get()).isEqualTo(3);
assertThat(psUtil.get(db, ctl.getNotes(), ps1.getId())).isNotNull();
assertThat(psUtil.get(db, ctl.getNotes(), ps2.getId())).isNull();
assertThat(psUtil.get(db, ctl.getNotes(), ps3.getId())).isNotNull();
assertThat(psUtil.get(db, ctl.getNotes(), ps4.getId())).isNull();
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method onlyPatchSetObjectMissingWithFix.
@Test
public void onlyPatchSetObjectMissingWithFix() throws Exception {
Change c = TestChanges.newChange(project, admin.getId(), sequences.nextChangeId());
PatchSet.Id psId = c.currentPatchSetId();
String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
PatchSet ps = newPatchSet(psId, rev, adminId);
if (notesMigration.changePrimaryStorage() == PrimaryStorage.REVIEW_DB) {
db.changes().insert(singleton(c));
db.patchSets().insert(singleton(ps));
}
addNoteDbCommit(c.getId(), "Create change\n" + "\n" + "Patch-set: 1\n" + "Branch: " + c.getDest().get() + "\n" + "Change-id: " + c.getKey().get() + "\n" + "Subject: Bogus subject\n" + "Commit: " + rev + "\n" + "Groups: " + rev + "\n");
indexer.index(db, c.getProject(), c.getId());
IdentifiedUser user = userFactory.create(admin.getId());
ChangeControl ctl = changeControlFactory.controlFor(db, c.getProject(), c.getId(), user);
FixInput fix = new FixInput();
fix.deletePatchSetIfCommitMissing = true;
assertProblems(ctl, fix, problem("Ref missing: " + ps.getId().toRefName()), problem("Object missing: patch set 1: " + rev, FIX_FAILED, "Cannot delete patch set; no patch sets would remain"));
ctl = reload(ctl);
assertThat(ctl.getChange().currentPatchSetId().get()).isEqualTo(1);
assertThat(psUtil.current(db, ctl.getNotes())).isNotNull();
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method patchSetObjectAndRefMissing.
// No test for ref existing but object missing; InMemoryRepository won't let
// us do such a thing.
@Test
public void patchSetObjectAndRefMissing() throws Exception {
String rev = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
ChangeControl ctl = insertChange();
PatchSet ps = insertMissingPatchSet(ctl, rev);
ctl = reload(ctl);
assertProblems(ctl, null, problem("Ref missing: " + ps.getId().toRefName()), problem("Object missing: patch set 2: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method patchSetObjectAndRefMissingWithDeletingPatchSet.
@Test
public void patchSetObjectAndRefMissingWithDeletingPatchSet() throws Exception {
ChangeControl ctl = insertChange();
PatchSet ps1 = psUtil.current(db, ctl.getNotes());
String rev2 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
PatchSet ps2 = insertMissingPatchSet(ctl, rev2);
ctl = reload(ctl);
FixInput fix = new FixInput();
fix.deletePatchSetIfCommitMissing = true;
assertProblems(ctl, fix, problem("Ref missing: " + ps2.getId().toRefName()), problem("Object missing: patch set 2: " + rev2, FIXED, "Deleted patch set"));
ctl = reload(ctl);
assertThat(ctl.getChange().currentPatchSetId().get()).isEqualTo(1);
assertThat(psUtil.get(db, ctl.getNotes(), ps1.getId())).isNotNull();
assertThat(psUtil.get(db, ctl.getNotes(), ps2.getId())).isNull();
}
Aggregations