use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullCommentTest method patchesComment.
/**
* RtPullComment can create a patch request.
* @throws Exception If a problem occurs.
*/
@Test
public void patchesComment() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")).start();
final Pull pull = Mockito.mock(Pull.class);
Mockito.doReturn(repo()).when(pull).repo();
final RtPullComment comment = new RtPullComment(new ApacheRequest(container.home()), pull, 2);
try {
final JsonObject json = Json.createObjectBuilder().add("body", "test comment").build();
comment.patch(json);
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
MatcherAssert.assertThat(query.body(), Matchers.containsString("{\"body\":\"test comment\"}"));
MatcherAssert.assertThat(query.uri().toString(), Matchers.endsWith("/repos/joe/blueharvest/pulls/comments/2"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullTest method fetchesFiles.
/**
* RtPull should be able to retrieve files.
*
* @throws Exception when a problem occurs.
*/
@Test
public void fetchesFiles() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[{\"file1\":\"testFile\"}]")).start();
final RtPull pull = new RtPull(new ApacheRequest(container.home()), this.repo(), 2);
try {
MatcherAssert.assertThat(pull.files().iterator().next().getString("file1"), Matchers.equalTo("testFile"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferenceTest method returnsRef.
/**
* RtReference should be able to return its ref.
* @throws Exception - If something goes wrong.
*/
@Test
public void returnsRef() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/featureC\"}")).start();
final Reference reference = new RtReference(new ApacheRequest(container.home()), new MkGithub().randomRepo(), "refs/heads/featureC");
try {
MatcherAssert.assertThat(reference.ref(), Matchers.is("refs/heads/featureC"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferencesTest method iteratesTags.
/**
* RtReferences should be able to iterate over tags.
* @throws Exception - If something goes wrong.
*/
@Test
public void iteratesTags() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[{\"ref\":\"refs/tags/feature-b\"}]")).start();
final References refs = new RtReferences(new ApacheRequest(container.home()), new MkGithub().randomRepo());
try {
MatcherAssert.assertThat(refs.tags(), Matchers.<Reference>iterableWithSize(1));
MatcherAssert.assertThat(container.take().uri().toString(), Matchers.endsWith("/git/refs/tags"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferencesTest method iteratesHeads.
/**
* RtReferences should be able to iterate over heads.
* @throws Exception - If something goes wrong.
*/
@Test
public void iteratesHeads() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[{\"ref\":\"refs/heads/feature-c\"}]")).start();
final References refs = new RtReferences(new ApacheRequest(container.home()), new MkGithub().randomRepo());
try {
MatcherAssert.assertThat(refs.heads(), Matchers.<Reference>iterableWithSize(1));
MatcherAssert.assertThat(container.take().uri().toString(), Matchers.endsWith("/git/refs/heads"));
} finally {
container.stop();
}
}
Aggregations