use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtPullsTest method getSinglePull.
/**
* RtPulls can get a single pull request.
* @throws Exception if some problem inside
*/
@Test
public void getSinglePull() throws Exception {
final String title = "new-feature";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, pull(title).toString())).start();
final RtPulls pulls = new RtPulls(new ApacheRequest(container.home()), repo());
final Pull pull = pulls.get(Tv.BILLION);
MatcherAssert.assertThat(new Pull.Smart(pull).title(), Matchers.equalTo(title));
container.stop();
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtPullsTest method createPull.
/**
* RtPulls can create a pull request.
*
* @throws Exception if some problem inside
*/
@Test
public void createPull() throws Exception {
final String title = "new feature";
final String body = pull(title).toString();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, body)).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body)).start();
final RtPulls pulls = new RtPulls(new ApacheRequest(container.home()), repo());
final Pull pull = pulls.create(title, "octocat", "master");
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
MatcherAssert.assertThat(new Pull.Smart(pull).title(), Matchers.equalTo(title));
container.stop();
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtReferencesTest method iteratesReferences.
/**
* RtReferences should be able to iterate over References.
* @throws Exception - If something goes wrong.
*/
@Test
public void iteratesReferences() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/feature-a\"}")).start();
final References refs = new RtReferences(new ApacheRequest(container.home()), new MkGithub().randomRepo());
try {
MatcherAssert.assertThat(refs.iterate(), Matchers.notNullValue());
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtReleaseAssetTest method patchesAsset.
/**
* RtReleaseAsset can create a patch request.
* @throws Exception If a problem occurs.
*/
@Test
public void patchesAsset() 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(), 2);
try {
final JsonObject json = Json.createObjectBuilder().add("name", "hello").build();
asset.patch(json);
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
MatcherAssert.assertThat(query.body(), Matchers.containsString("{\"name\":\"hello\"}"));
MatcherAssert.assertThat(query.uri().toString(), Matchers.endsWith("/repos/john/blueharvest/releases/assets/2"));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkGrizzlyContainer in project jcabi-github by jcabi.
the class RtReleaseAssetTest method removesAsset.
/**
* RtReleaseAsset can remove itself.
* @throws Exception If a problem occurs.
*/
@Test
public void removesAsset() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final RtReleaseAsset asset = new RtReleaseAsset(new ApacheRequest(container.home()), release(), 3);
try {
asset.remove();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
Aggregations