use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtDeployKeyTest method canDeleteDeployKey.
/**
* RtDeployKey can delete a deploy key.
*
* @throws Exception If some problem inside.
*/
@Test
public void canDeleteDeployKey() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start(this.resource.port());
final DeployKey key = new RtDeployKey(new ApacheRequest(container.home()), 3, RtDeployKeyTest.repo());
key.remove();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
container.stop();
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtEventTest method retrieveEventAsJson.
/**
* RtEvent can be retrieved in JSON form.
*
* @throws Exception If a problem occurs.
*/
@Test
public void retrieveEventAsJson() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"test\":\"events\"}")).start(this.resource.port());
final RtEvent event = new RtEvent(new ApacheRequest(container.home()), this.repo(), 3);
try {
MatcherAssert.assertThat(event.json().getString("test"), Matchers.equalTo("events"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtDeployKeysTest method canCreateDeployKey.
/**
* RtDeployKeys can create a key.
* @throws IOException If some problem inside.
*/
@Test
public void canCreateDeployKey() throws IOException {
final int number = 2;
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, String.format("{\"id\":%d}", number)));
container.start(this.resource.port());
try {
final DeployKeys keys = new RtDeployKeys(new ApacheRequest(container.home()), RtDeployKeysTest.repo());
MatcherAssert.assertThat(keys.create("Title", "Key").number(), Matchers.equalTo(number));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtForkTest method patchAndCheckJsonFork.
/**
* RtFork can patch comment and return new json.
* @throws IOException if has some problems with json parsing.
*/
@Test
public void patchAndCheckJsonFork() throws IOException {
final String original = "some organization";
final String patched = "some patched organization";
final MkContainer container = new MkGrizzlyContainer().next(this.answer(original)).next(this.answer(patched)).next(this.answer(original)).start(this.resource.port());
final MkContainer forksContainer = new MkGrizzlyContainer().start(this.resource.port());
final RtRepo repo = new RtRepo(new MkGithub(), new ApacheRequest(forksContainer.home()), new Coordinates.Simple("test_user", "test_repo"));
final RtFork fork = new RtFork(new ApacheRequest(container.home()), repo, 1);
fork.patch(RtForkTest.fork(patched));
MatcherAssert.assertThat(new Fork.Smart(fork).organization(), Matchers.equalTo(patched));
MatcherAssert.assertThat(new Fork.Smart(fork).name(), Matchers.notNullValue());
container.stop();
forksContainer.stop();
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtJsonTest method executePatchRequest.
/**
* RtJson can execute PATCH request.
*
* @throws Exception if there is any problem
*/
@Test
public void executePatchRequest() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"body\":\"hj\"}")).start();
final RtJson json = new RtJson(new ApacheRequest(container.home()));
json.patch(Json.createObjectBuilder().add("content", "hi you!").build());
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo("PATCH"));
container.stop();
}
Aggregations