use of com.jcabi.http.request.ApacheRequest 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.request.ApacheRequest 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.request.ApacheRequest 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.request.ApacheRequest 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();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtSearchTest method canSearchForContents.
/**
* RtSearch can search for contents.
*
* @throws Exception if a problem occurs
*/
@Test
public void canSearchForContents() throws Exception {
final JsonObject first = RtSearchTest.content("test/unit/attributes.js", "attributes.js", // @checkstyle LineLength (1 line)
"https://api.github.com/repos/user/repo/contents/test/unit/attributes.js?ref=f3b89ba0820882bd4ce4404b7e7c819e7b506de5").build();
final JsonObject second = RtSearchTest.content("src/attributes/classes.js", "classes.js", // @checkstyle LineLength (1 line)
"https://api.github.com/repos/user/repo/contents/src/attributes/classes.js?ref=f3b89ba0820882bd4ce4404b7e7c819e7b506de5").build();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(RtSearchTest.search(first, second).toString())).next(new MkAnswer.Simple(first.toString())).next(new MkAnswer.Simple(second.toString())).start();
try {
final Search search = new RtGithub(new ApacheRequest(container.home())).search();
MatcherAssert.assertThat(search.codes("test4", "joined", Search.Order.DESC), Matchers.<Content>iterableWithSize(2));
} finally {
container.stop();
}
}
Aggregations