Search in sources :

Example 31 with JdkRequest

use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.

the class RtPullCommentsTest method iteratesRepoPullComments.

/**
 * RtPullComments can fetch all pull comments for a repo.
 *
 * @throws Exception If something goes wrong.
 */
@Test
public void iteratesRepoPullComments() throws Exception {
    final Pull pull = Mockito.mock(Pull.class);
    Mockito.doReturn(repo()).when(pull).repo();
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(comment("comment 1")).add(comment("comment 2")).build().toString())).start(this.resource.port());
    try {
        final RtPullComments comments = new RtPullComments(new JdkRequest(container.home()), pull);
        MatcherAssert.assertThat(comments.iterate(Collections.<String, String>emptyMap()), Matchers.<PullComment>iterableWithSize(2));
    } finally {
        container.stop();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 32 with JdkRequest

use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.

the class RtPullCommentsTest method iteratesPullRequestComments.

/**
 * RtPullComments can fetch pull comments for a pull request.
 *
 * @throws Exception If something goes wrong.
 */
@Test
public void iteratesPullRequestComments() throws Exception {
    final Pull pull = Mockito.mock(Pull.class);
    Mockito.doReturn(repo()).when(pull).repo();
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(comment("comment 3")).add(comment("comment 4")).build().toString())).start(this.resource.port());
    try {
        final RtPullComments comments = new RtPullComments(new JdkRequest(container.home()), pull);
        MatcherAssert.assertThat(comments.iterate(1, Collections.<String, String>emptyMap()), Matchers.<PullComment>iterableWithSize(2));
    } finally {
        container.stop();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) JdkRequest(com.jcabi.http.request.JdkRequest) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Aggregations

JdkRequest (com.jcabi.http.request.JdkRequest)32 Test (org.junit.Test)32 MkContainer (com.jcabi.http.mock.MkContainer)31 MkGrizzlyContainer (com.jcabi.http.mock.MkGrizzlyContainer)31 MkAnswer (com.jcabi.http.mock.MkAnswer)8 MkQuery (com.jcabi.http.mock.MkQuery)4 MkGithub (com.jcabi.github.mock.MkGithub)2 RestResponse (com.jcabi.http.response.RestResponse)2 XmlResponse (com.jcabi.http.response.XmlResponse)1 ArrayMap (com.jcabi.immutable.ArrayMap)1 FkBase (io.wring.fake.FkBase)1 EnumMap (java.util.EnumMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Take (org.takes.Take)1 FtRemote (org.takes.http.FtRemote)1