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());
}
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));
}
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));
}
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!"));
}
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)));
}
Aggregations