use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtGistCommentsTest method iterateComments.
/**
* RtGistComments can iterate comments.
* @throws Exception if there is any error
*/
@Test
public void iterateComments() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(comment("comment 1")).add(comment("comment 2")).build().toString())).start(this.resource.port());
final Gist gist = Mockito.mock(Gist.class);
Mockito.doReturn("2").when(gist).identifier();
final RtGistComments comments = new RtGistComments(new JdkRequest(container.home()), gist);
MatcherAssert.assertThat(comments.iterate(), Matchers.<GistComment>iterableWithSize(2));
container.stop();
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtGistCommentsTest method getComment.
/**
* RtGistComments can get a single comment.
* @throws Exception if some problem inside
*/
@Test
public void getComment() throws Exception {
final String body = "Just commenting";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, comment(body).toString())).start(this.resource.port());
final Gist gist = Mockito.mock(Gist.class);
Mockito.doReturn("1").when(gist).identifier();
final RtGistComments comments = new RtGistComments(new JdkRequest(container.home()), gist);
final GistComment comment = comments.get(1);
MatcherAssert.assertThat(new GistComment.Smart(comment).body(), Matchers.equalTo(body));
container.stop();
}
use of com.jcabi.http.request.JdkRequest 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.request.JdkRequest in project jcabi-github by jcabi.
the class RtHooksTest method canFetchEmptyListOfHooks.
/**
* RtHooks can fetch empty list of hooks.
* @throws Exception if some problem inside
*/
@Test
public void canFetchEmptyListOfHooks() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[]")).start();
final Hooks hooks = new RtHooks(new JdkRequest(container.home()), RtHooksTest.repo());
try {
MatcherAssert.assertThat(hooks.iterate(), Matchers.emptyIterable());
} finally {
container.stop();
}
}
use of com.jcabi.http.request.JdkRequest in project jcabi-github by jcabi.
the class RtIssuesTest method iterateIssues.
/**
* RtIssues can iterate issues.
* @throws Exception if there is any error
*/
@Test
public void iterateIssues() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(issue("new issue")).add(issue("code issue")).build().toString())).start(this.resource.port());
final RtIssues issues = new RtIssues(new JdkRequest(container.home()), repo());
MatcherAssert.assertThat(issues.iterate(new ArrayMap<String, String>()), Matchers.<Issue>iterableWithSize(2));
container.stop();
}
Aggregations