use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPublicMembersTest method iteratesPublicMembers.
/**
* RtPublicMembers can list the public members of the organization.
* @throws IOException If there is an I/O problem
*/
@Test
public void iteratesPublicMembers() throws IOException {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[{\"login\":\"octobat\"}]")).next(new MkAnswer.Simple(HttpURLConnection.HTTP_INTERNAL_ERROR)).start();
try {
final RtPublicMembers members = new RtPublicMembers(new ApacheRequest(container.home()), organization());
members.iterate().iterator().next();
final MkQuery req = container.take();
MatcherAssert.assertThat(req.method(), Matchers.equalTo(Request.GET));
MatcherAssert.assertThat(req.uri().toString(), Matchers.endsWith(MEMBERS_URL));
this.thrown.expect(AssertionError.class);
members.iterate().iterator().next();
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPublicMembersTest method concealsMembers.
/**
* RtPublicMembers can conceal a user's membership in the organization.
* @throws IOException If there is an I/O problem
*/
@Test
public void concealsMembers() throws IOException {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT)).next(new MkAnswer.Simple(HttpURLConnection.HTTP_INTERNAL_ERROR)).start();
try {
final RtPublicMembers members = new RtPublicMembers(new ApacheRequest(container.home()), organization());
members.conceal(user());
final MkQuery req = container.take();
MatcherAssert.assertThat(req.method(), Matchers.equalTo(Request.DELETE));
MatcherAssert.assertThat(req.body(), Matchers.isEmptyOrNullString());
MatcherAssert.assertThat(req.uri().toString(), Matchers.endsWith(MEMBER_URL));
this.thrown.expect(AssertionError.class);
members.conceal(user());
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullCommentsTest method createsPullComment.
/**
* RtPullComments can post a new a pull comment.
*
* @throws Exception If something goes wrong.
*/
@Test
public void createsPullComment() throws Exception {
// @checkstyle MultipleStringLiterals (3 line)
final String body = "test-body";
final String commit = "test-commit-id";
final String path = "test-path";
final int position = 4;
final String response = pulls(body, commit, path, position).toString();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, response)).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, response)).start(this.resource.port());
final Pull pull = Mockito.mock(Pull.class);
Mockito.doReturn(repo()).when(pull).repo();
final RtPullComments pullComments = new RtPullComments(new ApacheRequest(container.home()), pull);
try {
final PullComment pullComment = pullComments.post(body, commit, path, position);
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
MatcherAssert.assertThat(new PullComment.Smart(pullComment).commitId(), Matchers.equalTo(commit));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullCommentsTest method createsPullCommentReply.
/**
* RtPullComments can reply to an existing pull comment.
*
* @throws Exception If something goes wrong.
*/
@Test
public void createsPullCommentReply() throws Exception {
final String body = "test-body";
final int number = 4;
final String response = Json.createObjectBuilder().add("id", Tv.BILLION).add("body", body).add("in_reply_to", number).build().toString();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, response)).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, response)).start(this.resource.port());
final Pull pull = Mockito.mock(Pull.class);
Mockito.doReturn(repo()).when(pull).repo();
final RtPullComments pullComments = new RtPullComments(new ApacheRequest(container.home()), pull);
try {
final PullComment pullComment = pullComments.reply(body, number);
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
MatcherAssert.assertThat(new PullComment.Smart(pullComment).reply(), Matchers.equalTo(number));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullsTest method getSinglePull.
/**
* RtPulls can get a single pull request.
* @throws Exception if some problem inside
*/
@Test
public void getSinglePull() throws Exception {
final String title = "new-feature";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, pull(title).toString())).start();
final RtPulls pulls = new RtPulls(new ApacheRequest(container.home()), repo());
final Pull pull = pulls.get(Tv.BILLION);
MatcherAssert.assertThat(new Pull.Smart(pull).title(), Matchers.equalTo(title));
container.stop();
}
Aggregations