use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullsTest method iteratePulls.
/**
* RtPulls can iterate pulls.
* @throws Exception if there is any error
*/
@Test
public void iteratePulls() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(pull("new-topic")).add(pull("Amazing new feature")).build().toString())).start();
final RtPulls pulls = new RtPulls(new ApacheRequest(container.home()), repo());
MatcherAssert.assertThat(pulls.iterate(new ArrayMap<String, String>()), Matchers.<Pull>iterableWithSize(2));
container.stop();
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReleaseAssetTest method rawAsset.
/**
* RtReleaseAsset can stream raw content.
* @throws Exception If a problem occurs.
*/
@Test
public void rawAsset() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")).start();
final RtReleaseAsset asset = new RtReleaseAsset(new ApacheRequest(container.home()), release(), 4);
try {
final InputStream stream = asset.raw();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.GET));
MatcherAssert.assertThat(IOUtils.toString(stream, StandardCharsets.UTF_8), Matchers.notNullValue());
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReleaseTest method release.
/**
* Create a test release.
* @param uri REST API entry point.
* @return A test release.
*/
private static RtRelease release(final URI uri) {
final Repo repo = Mockito.mock(Repo.class);
final Coordinates coords = Mockito.mock(Coordinates.class);
Mockito.doReturn(coords).when(repo).coordinates();
Mockito.doReturn("tstuser").when(coords).user();
Mockito.doReturn("tstbranch").when(coords).repo();
return new RtRelease(new ApacheRequest(uri), repo, 2);
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReleasesTest method canDeleteRelease.
/**
* RtReleases can delete a release.
* @throws Exception If some problem inside
*/
@Test
public void canDeleteRelease() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final Releases releases = new RtReleases(new ApacheRequest(container.home()), RtReleasesTest.repo());
try {
releases.remove(1);
final MkQuery query = container.take();
MatcherAssert.assertThat(query.uri().toString(), Matchers.endsWith("/releases/1"));
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtRepoTest method fetchLanguages.
/**
* RtRepo can fetch languages.
* @throws Exception if a problem occurs.
*/
@Test
public void fetchLanguages() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createObjectBuilder().add("Ruby", 1).build().toString())).start();
try {
final Repo repo = RtRepoTest.repo(new ApacheRequest(container.home()));
MatcherAssert.assertThat(repo.languages(), Matchers.notNullValue());
} finally {
container.stop();
}
}
Aggregations