Package com.jcabi.http.request

Examples of com.jcabi.http.request.FakeRequest


     */
    @Test
    public void canObtainOwnRelease() throws Exception {
        final Release release = release();
        final RtReleaseAsset asset = new RtReleaseAsset(
            new FakeRequest(),
            release,
            1
        );
        MatcherAssert.assertThat(
            asset.release(),
View Full Code Here


    @Test
    public void iteratesItems() {
        final String key = "key";
        final String value = "value";
        final Iterable<String> pagination = new RtSearchPagination<String>(
            new FakeRequest().withBody(
                Json.createObjectBuilder().add(
                    "items", Json.createArrayBuilder().add(
                        Json.createObjectBuilder().add(key, value)
                    )
                ).build().toString()
View Full Code Here

     */
    @Test
    public void canCompareInstances() throws Exception {
        final Repo repo = repo();
        final Issue issue = repo.issues().create("title", "body");
        final RtComment less = new RtComment(new FakeRequest(), issue, 1);
        final RtComment greater = new RtComment(new FakeRequest(), issue, 2);
        MatcherAssert.assertThat(
            less.compareTo(greater), Matchers.lessThan(0)
        );
        MatcherAssert.assertThat(
            greater.compareTo(less), Matchers.greaterThan(0)
View Full Code Here

     */
    @Test
    public void returnsItsIssue() throws Exception {
        final Repo repo = repo();
        final Issue issue = repo.issues().create("testing1", "issue1");
        final RtComment comment = new RtComment(new FakeRequest(), issue, 1);
        MatcherAssert.assertThat(comment.issue(), Matchers.is(issue));
    }
View Full Code Here

    @Test
    public void returnsItsNumber() throws Exception {
        final Repo repo = repo();
        final Issue issue = repo.issues().create("testing2", "issue2");
        final int num = 10;
        final RtComment comment = new RtComment(new FakeRequest(), issue, num);
        MatcherAssert.assertThat(comment.number(), Matchers.is(num));
    }
View Full Code Here

    public void waitUntilReset() throws IOException {
        final int threshold = 10;
        // @checkstyle MagicNumber (2 lines)
        final long reset = TimeUnit.MILLISECONDS
            .toSeconds(System.currentTimeMillis()) + 5L;
        new FakeRequest()
            .withStatus(HttpURLConnection.HTTP_OK)
            .withReason("OK")
            .withHeader("X-RateLimit-Remaining", "9")
            .withHeader("X-RateLimit-Reset", String.valueOf(reset))
            .through(CarefulWire.class, threshold)
View Full Code Here

     */
    @Test
    public void canSearchForRepos() throws Exception {
        final String coords = "test-user1/test-repo1";
        final Search search = new RtGithub(
            new FakeRequest().withBody(
                RtSearchTest.search(
                    Json.createObjectBuilder().add("full_name", coords).build()
                ).toString()
            )
        ).search();
View Full Code Here

     */
    @Test
    public void canSearchForIssues() throws Exception {
        final int number = 1;
        final Search search = new RtGithub(
            new FakeRequest().withBody(
                RtSearchTest.search(
                    Json.createObjectBuilder().add(
                        "url", String.format(
                            // @checkstyle LineLength (1 line)
                            "https://api.github.com/repos/user/repo/issues/%s",
View Full Code Here

     */
    @Test
    public void canSearchForUsers() throws Exception {
        final String login = "test-user";
        final Search search = new RtGithub(
            new FakeRequest().withBody(
                RtSearchTest.search(
                    Json.createObjectBuilder()
                        .add("login", login).build()
                ).toString()
            )
View Full Code Here

     * RtSearch can read non-unicode.
     * @throws Exception if any problem inside
     */
    @Test
    public void readNonUnicode() throws Exception {
        final Response resp = new FakeRequest()
            .withBody("{\"help\": \"\u001Fblah\u0001cwhoa\u0000!\"}").fetch();
        final JsonResponse response = new JsonResponse(resp);
        MatcherAssert.assertThat(
            response.json().readObject().getString("help"),
            Matchers.is("\u001Fblah\u0001cwhoa\u0000!")
View Full Code Here

TOP

Related Classes of com.jcabi.http.request.FakeRequest

Copyright © 2018 www.massapicom. 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.