mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 08:21:23 +00:00
Push method code coverage bar to 50 percent
This change adds or update a swath of tests to push method code coverage numbers up. Yes, method coverage is not super meaningful, but it is one metric that we can use to ensure at least minimal coverage of this library. Almost no product changes in here.
This commit is contained in:
@@ -5,7 +5,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -112,28 +111,52 @@ public class GHPullRequestTest extends AbstractGitHubWireMockTest {
|
||||
public void pullRequestReviewComments() throws Exception {
|
||||
String name = "pullRequestReviewComments";
|
||||
GHPullRequest p = getRepository().createPullRequest(name, "test/stable", "master", "## test");
|
||||
// System.out.println(p.getUrl());
|
||||
assertTrue(p.listReviewComments().toList().isEmpty());
|
||||
p.createReviewComment("Sample review comment", p.getHead().getSha(), "README.md", 1);
|
||||
List<GHPullRequestReviewComment> comments = p.listReviewComments().toList();
|
||||
assertEquals(1, comments.size());
|
||||
GHPullRequestReviewComment comment = comments.get(0);
|
||||
assertEquals("Sample review comment", comment.getBody());
|
||||
try {
|
||||
// System.out.println(p.getUrl());
|
||||
assertTrue(p.listReviewComments().toList().isEmpty());
|
||||
p.createReviewComment("Sample review comment", p.getHead().getSha(), "README.md", 1);
|
||||
List<GHPullRequestReviewComment> comments = p.listReviewComments().toList();
|
||||
assertEquals(1, comments.size());
|
||||
GHPullRequestReviewComment comment = comments.get(0);
|
||||
assertEquals("Sample review comment", comment.getBody());
|
||||
assertThat(comment.getInReplyToId(), equalTo(-1L));
|
||||
assertThat(comment.getPath(), equalTo("README.md"));
|
||||
assertThat(comment.getPosition(), equalTo(1));
|
||||
assertThat(comment.getUser(), notNullValue());
|
||||
// Assert htmlUrl is not null
|
||||
assertThat(comment.getHtmlUrl(), notNullValue());
|
||||
assertThat(comment.getHtmlUrl().toString(),
|
||||
containsString("hub4j-test-org/github-api/pull/" + p.getNumber()));
|
||||
|
||||
// Assert htmlUrl is not null
|
||||
assertNotNull(comment.getHtmlUrl());
|
||||
assertEquals(new URL("https://github.com/hub4j-test-org/github-api/pull/266#discussion_r321995146"),
|
||||
comment.getHtmlUrl());
|
||||
List<GHReaction> reactions = comment.listReactions().toList();
|
||||
assertThat(reactions.size(), equalTo(0));
|
||||
|
||||
comment.update("Updated review comment");
|
||||
comments = p.listReviewComments().toList();
|
||||
assertEquals(1, comments.size());
|
||||
comment = comments.get(0);
|
||||
assertEquals("Updated review comment", comment.getBody());
|
||||
GHReaction reaction = comment.createReaction(ReactionContent.CONFUSED);
|
||||
assertThat(reaction.getContent(), equalTo(ReactionContent.CONFUSED));
|
||||
|
||||
comment.delete();
|
||||
comments = p.listReviewComments().toList();
|
||||
assertTrue(comments.isEmpty());
|
||||
reactions = comment.listReactions().toList();
|
||||
assertThat(reactions.size(), equalTo(1));
|
||||
|
||||
GHPullRequestReviewComment reply = comment.reply("This is a reply.");
|
||||
assertThat(reply.getInReplyToId(), equalTo(comment.getId()));
|
||||
comments = p.listReviewComments().toList();
|
||||
|
||||
assertEquals(2, comments.size());
|
||||
|
||||
comment.update("Updated review comment");
|
||||
comments = p.listReviewComments().toList();
|
||||
comment = comments.get(0);
|
||||
assertEquals("Updated review comment", comment.getBody());
|
||||
|
||||
comment.delete();
|
||||
comments = p.listReviewComments().toList();
|
||||
// Reply is still present after delete of original comment, but no longer has replyToId
|
||||
assertThat(comments.size(), equalTo(1));
|
||||
assertThat(comments.get(0).getId(), equalTo(reply.getId()));
|
||||
assertThat(comments.get(0).getInReplyToId(), equalTo(-1L));
|
||||
} finally {
|
||||
p.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -412,15 +435,15 @@ public class GHPullRequestTest extends AbstractGitHubWireMockTest {
|
||||
public void getUserTest() throws IOException {
|
||||
GHPullRequest p = getRepository().createPullRequest("getUserTest", "test/stable", "master", "## test");
|
||||
GHPullRequest prSingle = getRepository().getPullRequest(p.getNumber());
|
||||
assertNotNull(prSingle.getUser().root);
|
||||
assertNotNull(prSingle.getUser().getRoot());
|
||||
prSingle.getMergeable();
|
||||
assertNotNull(prSingle.getUser().root);
|
||||
assertNotNull(prSingle.getUser().getRoot());
|
||||
|
||||
PagedIterable<GHPullRequest> ghPullRequests = getRepository().listPullRequests(GHIssueState.OPEN);
|
||||
for (GHPullRequest pr : ghPullRequests) {
|
||||
assertNotNull(pr.getUser().root);
|
||||
assertNotNull(pr.getUser().getRoot());
|
||||
pr.getMergeable();
|
||||
assertNotNull(pr.getUser().root);
|
||||
assertNotNull(pr.getUser().getRoot());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user