use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferenceTest method returnsOwner.
/**
* RtReference should be able to return its owner repo.
* @throws Exception - If something goes wrong.
*/
@Test
public void returnsOwner() throws Exception {
final Repo owner = new MkGithub().randomRepo();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/featureD\"}")).start();
final Reference reference = new RtReference(new ApacheRequest(container.home()), owner, "refs/heads/featureD");
try {
MatcherAssert.assertThat(reference.repo(), Matchers.is(owner));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferenceTest method patchesContent.
/**
* RtReference should be able to execute patch.
* @throws Exception - If something goes wrong.
*/
@Test
public void patchesContent() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/featureA\"}")).start();
final Reference reference = new RtReference(new ApacheRequest(container.home()), new MkGithub().randomRepo(), "refs/heads/featureA");
try {
reference.patch(Json.createObjectBuilder().add("sha", "abcdef12345").add("force", "false").build());
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.PATCH));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferencesTest method removesReference.
/**
* RtReferences should be able to remove a Reference.
* @throws Exception - If somethins goes wrong.
*/
@Test
public void removesReference() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final References refs = new RtReferences(new ApacheRequest(container.home()), new MkGithub().randomRepo());
refs.remove("heads/feature-a");
try {
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.DELETE));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtReferencesTest method createsReference.
/**
* RtReferences should create and return a Reference.
* @throws Exception - if something goes wrong.
*/
@Test
public void createsReference() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, "{\"ref\":\"refs/heads/feature-a\"}")).start();
final References refs = new RtReferences(new ApacheRequest(container.home()), new MkGithub().randomRepo());
try {
MatcherAssert.assertThat(refs.create("abceefgh3456", "refs/heads/feature-a"), Matchers.instanceOf(Reference.class));
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
} finally {
container.stop();
}
}
use of com.jcabi.http.request.ApacheRequest in project jcabi-github by jcabi.
the class RtUserTest method executePatchRequest.
/**
* RtUser can execute PATCH request.
*
* @throws Exception if there is any problem
*/
@Test
public void executePatchRequest() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"login\":\"octocate\"}")).start();
final RtUser json = new RtUser(Mockito.mock(Github.class), new ApacheRequest(container.home()));
json.patch(Json.createObjectBuilder().add("location", "San Francisco").build());
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.PATCH));
container.stop();
}
Aggregations