Examples of MkContainer


Examples of com.jcabi.http.mock.MkContainer

     */
    @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();
        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();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     */
    @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();
        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();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

        final String body = "test-body";
        final String commit = "test-commit-id";
        final String path = "test-path";
        final int position = 4;
        final String response = pulls(body, commit, path, position).toString();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, response)
        ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, response))
            .start();
        final Pull pull = Mockito.mock(Pull.class);
        Mockito.doReturn(repo()).when(pull).repo();
        final RtPullComments pullComments = new RtPullComments(
            new ApacheRequest(container.home()),
                pull
        );
        try {
            final PullComment pullComment = pullComments.post(
                body, commit, path, position
            );
            MatcherAssert.assertThat(
                container.take().method(),
                Matchers.equalTo(Request.POST)
            );
            MatcherAssert.assertThat(
                new PullComment.Smart(pullComment).commitId(),
                Matchers.equalTo(commit)
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

            .add("id", Tv.BILLION)
            .add("body", body)
            .add("in_reply_to", number)
            .build()
            .toString();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, response)
        ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, response))
            .start();
        final Pull pull = Mockito.mock(Pull.class);
        Mockito.doReturn(repo()).when(pull).repo();
        final RtPullComments pullComments = new RtPullComments(
            new ApacheRequest(container.home()),
                pull
        );
        try {
            final PullComment pullComment = pullComments.reply(
                body, number
            );
            MatcherAssert.assertThat(
                container.take().method(),
                Matchers.equalTo(Request.POST)
            );
            MatcherAssert.assertThat(
                new PullComment.Smart(pullComment).reply(),
                Matchers.equalTo(number)
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception If something goes wrong.
     */
    @Test
    public void removesPullComment() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
        ).start();
        final Pull pull = Mockito.mock(Pull.class);
        Mockito.doReturn(repo()).when(pull).repo();
        final RtPullComments comments =
            new RtPullComments(new ApacheRequest(container.home()), pull);
        try {
            comments.remove(2);
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
                query.method(), Matchers.equalTo(Request.DELETE)
            );
            MatcherAssert.assertThat(
                query.uri().toString(),
                Matchers.endsWith("/repos/johnny/test/pulls/comments/2")
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception if a problem occurs.
     */
    @Test
    public void patchWithJson() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "response")
        ).start();
        final RtContent content = new RtContent(
            new ApacheRequest(container.home()),
            this.repo(),
            "path"
        );
        content.patch(
            Json.createObjectBuilder().add("patch", "test").build()
        );
        final MkQuery query = container.take();
        try {
            MatcherAssert.assertThat(
                query.method(),
                Matchers.equalTo(Request.PATCH)
            );
            MatcherAssert.assertThat(
                query.body(),
                Matchers.equalTo("{\"patch\":\"test\"}")
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * @throws Exception if a problem occurs.
     */
    @Test
    public void fetchesRawContent() throws Exception {
        final String raw = "the raw \u20ac";
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, raw)
        ).start();
        final InputStream stream = new RtContent(
            new ApacheRequest(container.home()),
            this.repo(),
            "raw"
        ).raw();
        try {
            MatcherAssert.assertThat(
                IOUtils.toString(stream, Charsets.UTF_8),
                Matchers.is(raw)
            );
            MatcherAssert.assertThat(
                container.take().headers().get(HttpHeaders.ACCEPT).get(0),
                Matchers.is("application/vnd.github.v3.raw")
            );
        } finally {
            stream.close();
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * @throws Exception If some problem inside
     */
    @Test
    public void addsEmails() throws Exception {
        final String email = "test1@email.com";
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_CREATED,
                String.format("[{\"email\":\"%s\"}]", email)
            )
        );
        container.start();
        try {
            final UserEmails emails = new RtUserEmails(
                new ApacheRequest(container.home())
            );
            MatcherAssert.assertThat(
                emails.add(Collections.singletonList(email)).iterator().next(),
                Matchers.equalTo(email)
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception If a problem occurs.
     */
    @Test
    public void returnsJsonOutput() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"a\":\"b\"}")
                .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML)
        ).start();
        final RtMarkdown markdown = new RtMarkdown(
            new MkGithub(),
            new ApacheRequest(container.home())
        );
        try {
            MatcherAssert.assertThat(
                markdown.render(
                    Json.createObjectBuilder().add("hello", "world").build()
                ),
                Matchers.equalTo("{\"a\":\"b\"}")
            );
            MatcherAssert.assertThat(
                container.take().body(),
                Matchers.equalTo("{\"hello\":\"world\"}")
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception If a problem occurs.
     */
    @Test
    public void returnsRawOutput() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "Test Output")
                .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML)
        ).start();
        final RtMarkdown markdown = new RtMarkdown(
            new MkGithub(),
            new ApacheRequest(container.home())
        );
        try {
            MatcherAssert.assertThat(
                markdown.raw("Hello World!"),
                Matchers.equalTo("Test Output")
            );
            MatcherAssert.assertThat(
                container.take().body(),
                Matchers.equalTo("Hello World!")
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.