Examples of MkContainer


Examples of com.jcabi.http.mock.MkContainer

     * RtMilestones can remove a milestone.
     * @throws Exception if some problem inside
     */
    @Test
    public void deleteMilestone() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
        ).start();
        final RtMilestones milestones = new RtMilestones(
            new ApacheRequest(container.home()),
            repo()
        );
        milestones.remove(1);
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.DELETE)
        );
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

    @Test
    public void createLabel() throws Exception {
        final String name = "API";
        final String color = "FFFFFF";
        final String body = label(name, color).toString();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, body)
        ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body)).start();
        final RtLabels labels = new RtLabels(
            new JdkRequest(container.home()),
            repo()
        );
        final Label label = labels.create(name, color);
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.POST)
        );
        MatcherAssert.assertThat(
            new Label.Smart(label).name(),
            Matchers.equalTo(name)
        );
        MatcherAssert.assertThat(
            new Label.Smart(label).color(),
            Matchers.equalTo(color)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     */
    @Test
    public void getSingleLabel() throws Exception {
        final String name = "bug";
        final String color = "f29513";
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                label(name, color).toString()
            )
        ).start();
        final RtLabels issues = new RtLabels(
            new JdkRequest(container.home()),
            repo()
        );
        final Label label = issues.get(name);
        MatcherAssert.assertThat(
            new Label.Smart(label).color(),
            Matchers.equalTo(color)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtLabels can delete a label.
     * @throws Exception if some problem inside
     */
    @Test
    public void deleteLabel() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
        ).start();
        final RtLabels issues = new RtLabels(
            new JdkRequest(container.home()),
            repo()
        );
        issues.delete("issue");
        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

     * RtLabels can iterate labels.
     * @throws Exception if there is any error
     */
    @Test
    public void iterateLabels() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                Json.createArrayBuilder()
                    .add(label("new issue", "f29512"))
                    .add(label("new bug", "f29522"))
                    .build().toString()
            )
        ).start();
        final RtLabels labels = new RtLabels(
            new JdkRequest(container.home()),
            repo()
        );
        MatcherAssert.assertThat(
            labels.iterate(),
            Matchers.<Label>iterableWithSize(2)
        );
        container.stop();
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     */
    @Test(expected = NoSuchElementException.class)
    public void throwsIfNoMoreElement() throws Exception {
        final String jeff = "other Jeff";
        final String mark = "other Mark";
        final MkContainer container = new MkGrizzlyContainer().next(
            RtValuePaginationTest.simple(jeff, mark)
        ).start();
        try {
            final Request request = new ApacheRequest(container.home());
            final RtValuePagination<JsonObject, JsonArray> page =
                new RtValuePagination<JsonObject, JsonArray>(
                    request,
                    new RtValuePagination.Mapping<JsonObject, JsonArray>() {
                        @Override
                        public JsonObject map(final JsonArray object) {
                            return Json.createObjectBuilder()
                                .add("id3", object.getString(0))
                                .add("id4", object.getString(1))
                                .build();
                        }
                    }
                );
            final Iterator<JsonObject> iterator = page.iterator();
            iterator.next();
            MatcherAssert.assertThat(
                iterator.next(),
                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 canCreateFiles() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_CREATED,
                "{\"id\":\"1\"}"
            )
        ).start();
        final Gists gists = new RtGists(
            new MkGithub(),
            new ApacheRequest(container.home())
        );
        try {
            MatcherAssert.assertThat(
                gists.create(Collections.singletonMap("test", ""), false),
                Matchers.notNullValue()
            );
            MatcherAssert.assertThat(
                container.take().body(),
                Matchers.startsWith("{\"files\":{\"test\":{\"content\":")
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     *
     * @throws Exception if a problem occurs.
     */
    @Test
    public void canRetrieveSpecificGist() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "testing")
        ).start();
        final Gists gists = new RtGists(
            new MkGithub(),
            new ApacheRequest(container.home())
        );
        try {
            MatcherAssert.assertThat(
                gists.get("gist"),
                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 canIterateThrouRtGists() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                "[{\"id\":\"hello\"}]"
            )
        ).start();
        final Gists gists = new RtGists(
            new MkGithub(),
            new ApacheRequest(container.home())
        );
        try {
            MatcherAssert.assertThat(
                gists.iterate().iterator().next(),
                Matchers.notNullValue()
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

Examples of com.jcabi.http.mock.MkContainer

     * RtGists can remove a gist by name.
     * @throws Exception - if something goes wrong.
     */
    @Test
    public void removesGistByName() throws Exception {
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_NO_CONTENT,
                ""
            )
        )
            .start();
        final Gists gists = new RtGists(
            new MkGithub(),
            new ApacheRequest(container.home())
        );
        try {
            gists.remove("12234");
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
                query.method(),
                Matchers.equalTo(Request.DELETE)
            );
        } 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.