Search in sources :

Example 1 with MkGithub

use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.

the class RtPullRefTest method fetchesRepo.

/**
 * RtPullRef can fetch its repo.
 * @throws IOException If there is an I/O problem.
 */
@Test
public void fetchesRepo() throws IOException {
    final Repo repo = new MkGithub().randomRepo();
    MatcherAssert.assertThat(RtPullRefTest.pullRef(repo).repo().coordinates(), Matchers.equalTo(repo.coordinates()));
}
Also used : MkGithub(com.jcabi.github.mock.MkGithub) Test(org.junit.Test)

Example 2 with MkGithub

use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.

the class RtReferencesTest method iteratesReferences.

/**
 * RtReferences should be able to iterate over References.
 * @throws Exception - If something goes wrong.
 */
@Test
public void iteratesReferences() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"ref\":\"refs/heads/feature-a\"}")).start();
    final References refs = new RtReferences(new ApacheRequest(container.home()), new MkGithub().randomRepo());
    try {
        MatcherAssert.assertThat(refs.iterate(), Matchers.notNullValue());
    } finally {
        container.stop();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) ApacheRequest(com.jcabi.http.request.ApacheRequest) MkGithub(com.jcabi.github.mock.MkGithub) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 3 with MkGithub

use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.

the class RtOrganizationTest method canFetchIssueAsJson.

/**
 * RtOrganization should be able to describe itself in JSON format.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canFetchIssueAsJson() throws Exception {
    final RtOrganization org = new RtOrganization(new MkGithub(), new FakeRequest().withBody("{\"organization\":\"json\"}"), "testJson");
    MatcherAssert.assertThat(org.json().getString("organization"), Matchers.equalTo("json"));
}
Also used : MkGithub(com.jcabi.github.mock.MkGithub) FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 4 with MkGithub

use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.

the class RtOrganizationTest method canRepresentAsString.

/**
 * RtOrganization can return a String representation correctly reflecting
 * its URI.
 *
 * @throws Exception if something goes wrong.
 */
@Test
public void canRepresentAsString() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "blah")).start();
    final RtOrganization org = new RtOrganization(new MkGithub(), new ApacheRequest(container.home()), "testToString");
    try {
        MatcherAssert.assertThat(org.toString(), Matchers.endsWith("/orgs/testToString"));
    } finally {
        container.stop();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) ApacheRequest(com.jcabi.http.request.ApacheRequest) MkGithub(com.jcabi.github.mock.MkGithub) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 5 with MkGithub

use of com.jcabi.github.mock.MkGithub 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();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) ApacheRequest(com.jcabi.http.request.ApacheRequest) MkGithub(com.jcabi.github.mock.MkGithub) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Aggregations

MkGithub (com.jcabi.github.mock.MkGithub)57 Test (org.junit.Test)55 MkContainer (com.jcabi.http.mock.MkContainer)40 MkGrizzlyContainer (com.jcabi.http.mock.MkGrizzlyContainer)40 ApacheRequest (com.jcabi.http.request.ApacheRequest)38 FakeRequest (com.jcabi.http.request.FakeRequest)10 MkAnswer (com.jcabi.http.mock.MkAnswer)7 MkQuery (com.jcabi.http.mock.MkQuery)6 JsonObject (javax.json.JsonObject)5 JdkRequest (com.jcabi.http.request.JdkRequest)2 Request (com.jcabi.http.Request)1 StringReader (java.io.StringReader)1