Search in sources :

Example 1 with DraftApi

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

the class RevisionIT method drafts.

@Test
public void drafts() throws Exception {
    PushOneCommit.Result r = createChange();
    DraftInput in = new DraftInput();
    in.line = 1;
    in.message = "nit: trailing whitespace";
    in.path = FILE_NAME;
    DraftApi draftApi = gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).createDraft(in);
    assertThat(draftApi.get().message).isEqualTo(in.message);
    assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).draft(draftApi.get().id).get().message).isEqualTo(in.message);
    assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).drafts()).hasSize(1);
    in.message = "good catch!";
    assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).draft(draftApi.get().id).update(in).message).isEqualTo(in.message);
    assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).draft(draftApi.get().id).get().author.email).isEqualTo(admin.email);
    draftApi.delete();
    assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).drafts()).isEmpty();
}
Also used : DraftApi(com.google.gerrit.extensions.api.changes.DraftApi) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 DraftApi (com.google.gerrit.extensions.api.changes.DraftApi)1 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)1 Test (org.junit.Test)1