Massaged the changes

- Restored binary compatibility. The draft API has changed in some
  significant way when it became public, and the PR took the liberty to
  delete removed constants and method signatures. I brought them back so
  that older clients can keep functioning.

- Introduced a builder pattern to create PR review

- replying to a review comment should be an instance method, not a
  static method.

- GHPullRequestReview and GHPullRequestReviewDraft was not making sense
  to me, since GitHub API doesn't differentiate them. It creates a
  practical problem of not being able to submit a review comment unless
  you created the review comment in the same JVM session. That said, I
  don't understand the point of this two phase approach in the GitHub
  API to begin with!
This commit is contained in:
Kohsuke Kawaguchi
2018-01-13 09:43:44 -08:00
parent e74346fed6
commit acbf286e59
10 changed files with 265 additions and 269 deletions

View File

@@ -7,8 +7,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.*;
/**
* @author Kohsuke Kawaguchi
@@ -33,9 +32,10 @@ public class PullRequestTest extends AbstractGitHubApiTestBase {
public void testPullRequestReviews() throws Exception {
String name = rnd.next();
GHPullRequest p = getRepository().createPullRequest(name, "stable", "master", "## test");
GHPullRequestReviewDraft draftReview = p.newDraftReview(null, "Some draft review",
GHPullRequestReviewComment.draft("Some niggle", "changelog.html", 1)
);
GHPullRequestReview draftReview = p.createReview()
.body("Some draft review")
.comment("Some niggle", "changelog.html", 1)
.create();
assertThat(draftReview.getState(), is(GHPullRequestReviewState.PENDING));
assertThat(draftReview.getBody(), is("Some draft review"));
assertThat(draftReview.getCommitId(), notNullValue());
@@ -50,9 +50,10 @@ public class PullRequestTest extends AbstractGitHubApiTestBase {
assertEquals(1, comments.size());
GHPullRequestReviewComment comment = comments.get(0);
assertEquals("Some niggle", comment.getBody());
draftReview = p.newDraftReview(null, "Some new review",
GHPullRequestReviewComment.draft("Some niggle", "changelog.html", 1)
);
draftReview = p.createReview()
.body("Some new review")
.comment("Some niggle", "changelog.html", 1)
.create();
draftReview.delete();
}