Examples of MkContainer


Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception if a problem occurs.
     */
    @Test
    public void retrievesKeys() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                Json.createArrayBuilder()
                    .add(key(1))
                    .add(key(2))
                    .build().toString()
            )
        ).start();
        final RtPublicKeys keys = new RtPublicKeys(
            new ApacheRequest(container.home()),
            Mockito.mock(User.class)
        );
        MatcherAssert.assertThat(
            keys.iterate(),
            Matchers.<PublicKey>iterableWithSize(2)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception if a problem occurs.
     */
    @Test
    public void canFetchSingleKey() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                ""
            )
        ).start();
        final RtPublicKeys keys = new RtPublicKeys(
            new ApacheRequest(container.home()),
            Mockito.mock(User.class)
        );
        try {
            MatcherAssert.assertThat(
                keys.get(1),
                Matchers.notNullValue()
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception if a problem occurs.
     */
    @Test
    public void canRemoveKey() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_NO_CONTENT,
                ""
            )
        ).start();
        final RtPublicKeys keys = new RtPublicKeys(
            new ApacheRequest(container.home()),
            Mockito.mock(User.class)
        );
        try {
            keys.remove(1);
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
                query.uri().toString(),
                Matchers.endsWith("/user/keys/1")
            );
            MatcherAssert.assertThat(
                query.method(),
                Matchers.equalTo(Request.DELETE)
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtPublicKeys can create a key.
     * @throws IOException If some problem inside.
     */
    @Test
    public void canCreatePublicKey() throws IOException {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_CREATED, key(1).toString()
            )
        ).start();
        try {
            final RtPublicKeys keys = new RtPublicKeys(
                new ApacheRequest(container.home()),
                Mockito.mock(User.class)
            );
            MatcherAssert.assertThat(
                keys.create("theTitle", "theKey").number(),
                Matchers.is(1)
            );
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
                query.uri().toString(),
                Matchers.endsWith("/user/keys")
            );
            MatcherAssert.assertThat(
                query.body(),
                Matchers.equalTo(
                    "{\"title\":\"theTitle\",\"key\":\"theKey\"}"
                )
            );
        } finally {
            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,
                "{\"login\":\"octocate\"}"
            )
        ).start();
        final RtUser json = new RtUser(
            Mockito.mock(Github.class),
            new ApacheRequest(container.home())
        );
        json.patch(
            Json.createObjectBuilder()
                .add("location", "San Francisco")
                .build()
        );
        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 createIssue() throws Exception {
        final String title = "Found a bug";
        final String body = issue(title).toString();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, body)
        ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body)).start();
        final RtIssues issues = new RtIssues(
            new JdkRequest(container.home()),
            repo()
        );
        final Issue issue = issues.create(title, "having a problem with it.");
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.POST)
        );
        MatcherAssert.assertThat(
            new Issue.Smart(issue).title(),
            Matchers.equalTo(title)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * @throws Exception if some problem inside
     */
    @Test
    public void getSingleIssue() throws Exception {
        final String title = "Unit test";
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                issue(title).toString()
            )
        ).start();
        final RtIssues issues = new RtIssues(
            new JdkRequest(container.home()),
            repo()
        );
        final Issue issue = issues.get(1);
        MatcherAssert.assertThat(
            new Issue.Smart(issue).title(),
            Matchers.equalTo(title)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtIssues can iterate issues.
     * @throws Exception if there is any error
     */
    @Test
    public void iterateIssues() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                Json.createArrayBuilder()
                    .add(issue("new issue"))
                    .add(issue("code issue"))
                    .build().toString()
            )
        ).start();
        final RtIssues issues = new RtIssues(
            new JdkRequest(container.home()),
            repo()
        );
        MatcherAssert.assertThat(
            issues.iterate(new ArrayMap<String, String>()),
            Matchers.<Issue>iterableWithSize(2)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtGist can unstar a starred Gist.
     * @throws Exception If something goes wrong.
     */
    @Test
    public void canUnstarAGist() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
        ).start();
        final RtGist gist = new RtGist(
            new MkGithub(),
            new ApacheRequest(container.home()),
            "unstar"
        );
        gist.unstar();
        final MkQuery query = container.take();
        MatcherAssert.assertThat(
            query.method(),
            Matchers.equalTo(Request.DELETE)
        );
        MatcherAssert.assertThat(
            query.body(),
            Matchers.isEmptyOrNullString()
        );
        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, "{\"msg\":\"hi\"}")
        ).start();
        try {
            final RtGist gist = new RtGist(
                new MkGithub(),
                new ApacheRequest(container.home()),
                "patch"
            );
            gist.patch(
                Json.createObjectBuilder()
                    .add("content", "hi you!")
                    .build()
            );
            MatcherAssert.assertThat(
                container.take().method(),
                Matchers.equalTo(Request.PATCH)
            );
        } 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.