use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtMilestonesTest method deleteMilestone.
/**
* RtMilestones can remove a milestone.
* @throws Exception if some problem inside
*/
@Test
public void deleteMilestone() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start(this.resource.port());
try {
final RtMilestones milestones = new RtMilestones(new ApacheRequest(container.home()), repo());
milestones.remove(1);
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtLabelTest method sendHttpRequestAndWriteResponseAsJson.
/**
* RtLabel can can fetch HTTP request and describe response as a JSON.
*
* @throws Exception if there is any problem
*/
@Test
public void sendHttpRequestAndWriteResponseAsJson() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"msg\": \"hi\"}")).start();
final RtLabel label = new RtLabel(new ApacheRequest(container.home()), RtLabelTest.repo(), "bug");
MatcherAssert.assertThat(label.json().getString("msg"), Matchers.equalTo("hi"));
container.stop();
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtOrganizationTest method patchWithJson.
/**
* RtOrganization should be able to perform a patch request.
*
* @throws Exception if a problem occurs.
*/
@Test
public void patchWithJson() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "response")).start();
final RtOrganization org = new RtOrganization(new MkGithub(), new ApacheRequest(container.home()), "testPatch");
org.patch(Json.createObjectBuilder().add("patch", "test").build());
final MkQuery query = container.take();
try {
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
MatcherAssert.assertThat(query.body(), Matchers.equalTo("{\"patch\":\"test\"}"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtOrganizationsTest method retrievesOrganizations.
/**
* RtOrganizations should be able to iterate
* the logged-in user's organizations.
*
* @throws Exception If a problem occurs
* @checkstyle MagicNumberCheck (25 lines)
*/
@Test
public void retrievesOrganizations() throws Exception {
final Github github = new MkGithub();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(org(1, "org1")).add(org(2, "org2")).add(org(3, "org3")).build().toString())).start(this.resource.port());
try {
final Organizations orgs = new RtOrganizations(github, new ApacheRequest(container.home()));
MatcherAssert.assertThat(orgs.iterate(), Matchers.<Organization>iterableWithSize(Tv.THREE));
MatcherAssert.assertThat(container.take().uri().toString(), Matchers.endsWith("/user/orgs"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtOrganizationsTest method fetchesSingleOrganization.
/**
* RtOrganizations should be able to get a single organization.
*
* @throws Exception if a problem occurs
*/
@Test
public void fetchesSingleOrganization() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")).start(this.resource.port());
try {
final Organizations orgs = new RtOrganizations(new MkGithub(), new ApacheRequest(container.home()));
MatcherAssert.assertThat(orgs.get("org"), Matchers.notNullValue());
} finally {
container.stop();
}
}
Aggregations