Search in sources :

Example 16 with FixInput

use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method patchSetObjectAndRefMissingWithDeletingPatchSet.

@Test
public void patchSetObjectAndRefMissingWithDeletingPatchSet() throws Exception {
    ChangeNotes notes = insertChange();
    PatchSet ps1 = psUtil.current(notes);
    String rev2 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
    PatchSet ps2 = insertMissingPatchSet(notes, rev2);
    notes = reload(notes);
    FixInput fix = new FixInput();
    fix.deletePatchSetIfCommitMissing = true;
    assertProblems(notes, fix, problem("Ref missing: " + ps2.id().toRefName()), problem("Object missing: patch set 2: " + rev2, FIXED, "Deleted patch set"));
    notes = reload(notes);
    assertThat(notes.getChange().currentPatchSetId().get()).isEqualTo(1);
    assertThat(psUtil.get(notes, ps1.id())).isNotNull();
    assertThat(psUtil.get(notes, ps2.id())).isNull();
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) TestChanges.newPatchSet(com.google.gerrit.testing.TestChanges.newPatchSet) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 17 with FixInput

use of com.google.gerrit.extensions.api.changes.FixInput in project gerrit by GerritCodeReview.

the class ConsistencyCheckerIT method newChangeIsMergedWithFix.

@Test
public void newChangeIsMergedWithFix() throws Exception {
    ChangeNotes notes = insertChange();
    ObjectId commitId = psUtil.current(notes).commitId();
    serverSideTestRepo.branch(notes.getChange().getDest().branch()).update(serverSideTestRepo.getRevWalk().parseCommit(commitId));
    assertProblems(notes, new FixInput(), problem("Patch set 1 (" + commitId.name() + ") is merged into destination ref" + " refs/heads/master (" + commitId.name() + "), but change status is NEW", FIXED, "Marked change as merged"));
    notes = reload(notes);
    assertThat(notes.getChange().isMerged()).isTrue();
    assertNoProblems(notes, null);
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) FixInput(com.google.gerrit.extensions.api.changes.FixInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

FixInput (com.google.gerrit.extensions.api.changes.FixInput)17 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)16 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)16 Test (org.junit.Test)16 PatchSet (com.google.gerrit.entities.PatchSet)10 TestChanges.newPatchSet (com.google.gerrit.testing.TestChanges.newPatchSet)10 RevCommit (org.eclipse.jgit.revwalk.RevCommit)7 ObjectId (org.eclipse.jgit.lib.ObjectId)5 Change (com.google.gerrit.entities.Change)1 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1 ChangeJson (com.google.gerrit.server.change.ChangeJson)1