use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtHooksTest method canDeleteHook.
/**
* RtHooks can delete a hook.
*
* @throws Exception if something goes wrong.
*/
@Test
public void canDeleteHook() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final Hooks hooks = new RtHooks(new JdkRequest(container.home()), RtHooksTest.repo());
hooks.remove(1);
try {
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
MatcherAssert.assertThat(query.body(), Matchers.isEmptyString());
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtCommentTest method patchesComment.
/**
* RtComment can patch a comment.
* @throws Exception - if anything goes wrong.
*/
@Test
public void patchesComment() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")).start(this.resource.port());
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing5", "issue5");
final RtComment comment = new RtComment(new ApacheRequest(container.home()), issue, 10);
final JsonObject jsonPatch = Json.createObjectBuilder().add("title", "test comment").build();
try {
comment.patch(jsonPatch);
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtCommentTest method removesComment.
/**
* This tests that the remove() method is working fine.
* @throws Exception - in case something goes wrong.
*/
@Test
public void removesComment() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start(this.resource.port());
final Repo repo = new MkGithub().randomRepo();
final Issue issue = repo.issues().create("testing3", "issue3");
final RtComment comment = new RtComment(new ApacheRequest(container.home()), issue, 10);
try {
comment.remove();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkQuery in project jcabi-github by jcabi.
the class RtIssueTest method patchWithJson.
/**
* RtIssue 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(this.resource.port());
final RtIssue issue = new RtIssue(new ApacheRequest(container.home()), this.repo(), 1);
issue.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.mock.MkQuery in project jcabi-github by jcabi.
the class RtCollaboratorsTest method userCanBeRemoved.
/**
* User can be removed from a list of collaborators.
* @throws Exception if any error occurs.
*/
@Test
public void userCanBeRemoved() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, Json.createArrayBuilder().add(RtCollaboratorsTest.json("octocat2")).add(RtCollaboratorsTest.json("dummy")).build().toString())).start(this.resource.port());
final Collaborators users = new RtCollaborators(new JdkRequest(container.home()), this.repo());
try {
users.remove("dummy");
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
Aggregations