use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullTest method fetchesCommits.
/**
* RtPull should be able to retrieve commits.
*
* @throws Exception when a problem occurs.
*/
@Test
public void fetchesCommits() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[{\"commits\":\"test\"}]")).start();
final RtPull pull = new RtPull(new ApacheRequest(container.home()), this.repo(), 1);
try {
MatcherAssert.assertThat(pull.commits(), Matchers.notNullValue());
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullTest method fetchesHead.
/**
* RtPull can fetch its head ref.
* @throws IOException If some I/O problem occurs
*/
@Test
public void fetchesHead() throws IOException {
final String ref = "neat-other-branch";
final String sha = "9c717b4716e4fc4d917f546e8e6b562e810e3922";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createObjectBuilder().add("head", Json.createObjectBuilder().add(RtPullTest.REF_PROP, ref).add(RtPullTest.SHA_PROP, sha).build()).build().toString())).start();
final RtPull pull = new RtPull(new ApacheRequest(container.home()), this.repo(), 1);
try {
final PullRef head = pull.head();
MatcherAssert.assertThat(head, Matchers.notNullValue());
MatcherAssert.assertThat(head.ref(), Matchers.equalTo(ref));
MatcherAssert.assertThat(head.sha(), Matchers.equalTo(sha));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullTest method executeMerge.
/**
* RtPull should be able to perform a merge.
*
* @throws Exception when a problem occurs.
*/
@Test
public void executeMerge() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "testMerge")).start();
final RtPull pull = new RtPull(new ApacheRequest(container.home()), this.repo(), 3);
pull.merge("Test commit.");
try {
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PUT));
MatcherAssert.assertThat(query.body(), Matchers.equalTo("{\"commit_message\":\"Test commit.\"}"));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtPullTest method fetchesBase.
/**
* RtPull can fetch its base ref.
* @throws IOException If some I/O problem occurs
*/
@Test
public void fetchesBase() throws IOException {
final String ref = "sweet-feature-branch";
final String sha = "e93c6a2216c69daa574abc16e7c14767fce44ad6";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createObjectBuilder().add("base", Json.createObjectBuilder().add(RtPullTest.REF_PROP, ref).add(RtPullTest.SHA_PROP, sha).build()).build().toString())).start();
final RtPull pull = new RtPull(new ApacheRequest(container.home()), this.repo(), 1);
try {
final PullRef base = pull.base();
MatcherAssert.assertThat(base, Matchers.notNullValue());
MatcherAssert.assertThat(base.ref(), Matchers.equalTo(ref));
MatcherAssert.assertThat(base.sha(), Matchers.equalTo(sha));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferenceTest method fetchesContent.
/**
* RtReference should be able to fetch its json.
* @throws Exception - if something goes wrong.
*/
@Test
public void fetchesContent() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/featureB\"}")).start();
final Reference reference = new RtReference(new ApacheRequest(container.home()), new MkGithub().randomRepo(), "refs/heads/featureB");
try {
MatcherAssert.assertThat(reference.json().getString("ref"), Matchers.is("refs/heads/featureB"));
} finally {
container.stop();
}
}
Aggregations