Examples of MkContainer


Examples of com.jcabi.http.mock.MkContainer

     * @throws Exception if some problem inside
     */
    @Test
    public void getComment() throws Exception {
        final String body = "Just commenting";
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                comment(body).toString()
            )
        ).start();
        final Gist gist = Mockito.mock(Gist.class);
        Mockito.doReturn("1").when(gist).identifier();
        final RtGistComments comments = new RtGistComments(
            new JdkRequest(container.home()),
            gist
        );
        final GistComment comment = comments.get(1);
        MatcherAssert.assertThat(
            new GistComment.Smart(comment).body(),
            Matchers.equalTo(body)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtGistComments can iterate comments.
     * @throws Exception if there is any error
     */
    @Test
    public void iterateComments() throws Exception {
        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();
        final Gist gist = Mockito.mock(Gist.class);
        Mockito.doReturn("2").when(gist).identifier();
        final RtGistComments comments = new RtGistComments(
            new JdkRequest(container.home()),
            gist
        );
        MatcherAssert.assertThat(
            comments.iterate(),
            Matchers.<GistComment>iterableWithSize(2)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

        final String body = "new commenting";
        final MkAnswer answer = new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            comment(body).toString()
        );
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_CREATED,
                comment(body).toString()
            )
        ).next(answer).start();
        final Gist gist = Mockito.mock(Gist.class);
        Mockito.doReturn("3").when(gist).identifier();
        final RtGistComments comments = new RtGistComments(
            new JdkRequest(container.home()),
            gist
        );
        final GistComment comment = comments.post(body);
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.POST)
        );
        MatcherAssert.assertThat(
            new GistComment.Smart(comment).body(),
            Matchers.equalTo(body)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception If some problem inside
     */
    @Test
    public void iteratesEvents() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                Json.createArrayBuilder()
                    .add(event(Event.ASSIGNED))
                    .add(event(Event.MENTIONED))
                    .build().toString()
            )
        ).start();
        final Repo repo = new RtRepo(
            Mockito.mock(Github.class),
            new ApacheRequest(container.home()),
            new Coordinates.Simple("octocat", "master")
        );
        MatcherAssert.assertThat(
            repo.events(),
            Matchers.<Event>iterableWithSize(2)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception if there is any problem
     */
    @Test
    public void executePatchRequest() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                event(Event.ASSIGNED).toString()
            )
        ).start();
        final Repo repo = new RtRepo(
            Mockito.mock(Github.class),
            new ApacheRequest(container.home()),
            new Coordinates.Simple("test", "test-branch")
        );
        repo.patch(event(Event.ASSIGNED));
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.PATCH)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

    @Test
    public void createRepo() throws Exception {
        final String owner = "test-owner";
        final String name = "test-repo";
        final String response = response(owner, name).toString();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, response)
        ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, response))
            .start();
        final RtRepos repos = new RtRepos(
            Mockito.mock(Github.class),
            new ApacheRequest(container.home())
        );
        final Repo repo = this.rule.repo(repos);
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.POST)
        );
        MatcherAssert.assertThat(
            repo.coordinates(),
            Matchers.equalTo((Coordinates) new Coordinates.Simple(owner, name))
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * @throws Exception if there is any error
     */
    @Test
    public void iterateRepos() throws Exception {
        final String identifier = "1";
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                Json.createArrayBuilder()
                    .add(response("octocat", identifier))
                    .add(response("dummy", "2"))
                    .build().toString()
            )
        ).start();
        final RtRepos repos = new RtRepos(
            Mockito.mock(Github.class),
            new ApacheRequest(container.home())
        );
        MatcherAssert.assertThat(
            repos.iterate(identifier),
            Matchers.<Repo>iterableWithSize(2)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtRepos can remove a repo.
     * @throws Exception if some problem inside
     */
    @Test
    public void removeRepo() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
        ).start();
        final Repos repos = new RtRepos(
            Mockito.mock(Github.class),
            new ApacheRequest(container.home())
        );
        repos.remove(new Coordinates.Simple("", ""));
        try {
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
                query.method(),
                Matchers.equalTo(Request.DELETE)
            );
            MatcherAssert.assertThat(
                query.body(),
                Matchers.isEmptyString()
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

        final String organization = RandomStringUtils.randomAlphanumeric(10);
        final MkAnswer answer = new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            fork(organization).toString()
        );
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_ACCEPTED,
                fork(organization).toString()
            )
        ).next(answer).start();
        final Repo owner = Mockito.mock(Repo.class);
        final Coordinates coordinates = new Coordinates.Simple(
            "test_user", "test_repo"
        );
        Mockito.doReturn(coordinates).when(owner).coordinates();
        final RtForks forks = new RtForks(
            new JdkRequest(container.home()),
            owner
        );
        final Fork fork = forks.create(organization);
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.POST)
        );
        MatcherAssert.assertThat(
            fork.json().getString(ORGANIZATION),
            Matchers.equalTo(organization)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtHooks can fetch empty list of hooks.
     * @throws Exception if some problem inside
     */
    @Test
    public void canFetchEmptyListOfHooks() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[]")
        ).start();
        final Hooks hooks = new RtHooks(
            new JdkRequest(container.home()),
            RtHooksTest.repo()
        );
        try {
            MatcherAssert.assertThat(
                hooks.iterate(),
                Matchers.emptyIterable()
            );
        } 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.