Search in sources :

Example 6 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtReleasesTest method canFetchSingleRelease.

/**
 * RtReleases can fetch a single release.
 * @throws IOException If some problem inside
 */
@Test
public void canFetchSingleRelease() throws IOException {
    final Releases releases = new RtReleases(new FakeRequest(), RtReleasesTest.repo());
    MatcherAssert.assertThat(releases.get(1), Matchers.notNullValue());
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 7 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtSearchTest method canSearchForRepos.

/**
 * RtSearch can search for repos.
 *
 * @throws Exception if a problem occurs
 */
@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();
    MatcherAssert.assertThat(search.repos("test", "stars", Search.Order.DESC).iterator().next().coordinates().toString(), Matchers.equalTo(coords));
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 8 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtSearchTest method canSearchForIssues.

/**
 * RtSearch can search for issues.
 *
 * @throws Exception if a problem occurs
 */
@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", number)).add("number", number).build()).toString())).search();
    MatcherAssert.assertThat(search.issues("test2", "created", Search.Order.DESC, new EnumMap<Search.Qualifier, String>(Search.Qualifier.class)).iterator().next().number(), Matchers.equalTo(number));
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 9 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtSearchTest method readNonUnicode.

/**
 * 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!"));
}
Also used : Response(com.jcabi.http.Response) JsonResponse(com.jcabi.http.response.JsonResponse) JsonResponse(com.jcabi.http.response.JsonResponse) FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 10 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtRepoCommitTest method hasProperRequestUrl.

/**
 * RtRepoCommit has proper request URL.
 */
@Test
public final void hasProperRequestUrl() {
    final String sha = RandomStringUtils.randomAlphanumeric(50);
    final RtRepoCommit commit = new RtRepoCommit(new FakeRequest(), repo(), sha);
    MatcherAssert.assertThat(commit.toString(), Matchers.endsWith(String.format("/see-FakeRequest-class/repos/user/repo/commits/%s", sha)));
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Aggregations

FakeRequest (com.jcabi.http.request.FakeRequest)65 Test (org.junit.Test)65 MkGithub (com.jcabi.github.mock.MkGithub)9 JsonObject (javax.json.JsonObject)3 Request (com.jcabi.http.Request)2 ApacheRequest (com.jcabi.http.request.ApacheRequest)2 MkOrganization (com.jcabi.github.mock.MkOrganization)1 Response (com.jcabi.http.Response)1 MkContainer (com.jcabi.http.mock.MkContainer)1 MkGrizzlyContainer (com.jcabi.http.mock.MkGrizzlyContainer)1 JsonResponse (com.jcabi.http.response.JsonResponse)1