Search in sources :

Example 31 with MkGithub

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

the class RtGistsTest method canCreateFiles.

/**
 * RtGists can create new files.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canCreateFiles() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, "{\"id\":\"1\"}")).start(this.resource.port());
    final Gists gists = new RtGists(new MkGithub(), new ApacheRequest(container.home()));
    try {
        MatcherAssert.assertThat(gists.create(Collections.singletonMap("test", ""), false), Matchers.notNullValue());
        MatcherAssert.assertThat(container.take().body(), Matchers.startsWith("{\"files\":{\"test\":{\"content\":"));
    } 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 32 with MkGithub

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

the class RtGistsTest method canIterateThrouRtGists.

/**
 * RtGists can iterate through its contents.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canIterateThrouRtGists() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[{\"id\":\"hello\"}]")).start(this.resource.port());
    final Gists gists = new RtGists(new MkGithub(), new ApacheRequest(container.home()));
    try {
        MatcherAssert.assertThat(gists.iterate().iterator().next(), 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 33 with MkGithub

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

the class RtGistsTest method canRetrieveSpecificGist.

/**
 * RtGists can retrieve a specific Gist.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canRetrieveSpecificGist() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "testing")).start(this.resource.port());
    final Gists gists = new RtGists(new MkGithub(), new ApacheRequest(container.home()));
    try {
        MatcherAssert.assertThat(gists.get("gist"), 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 34 with MkGithub

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

the class RtBranchTest method fetchesCommit.

/**
 * RtBranch can fetch its commit.
 * @throws Exception if a problem occurs.
 */
@Test
public void fetchesCommit() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final Commit commit = RtBranchTest.newBranch(repo).commit();
    MatcherAssert.assertThat(commit.sha(), Matchers.equalTo(SHA));
    final Coordinates coords = commit.repo().coordinates();
    MatcherAssert.assertThat(coords.user(), Matchers.equalTo(repo.coordinates().user()));
    MatcherAssert.assertThat(coords.repo(), Matchers.equalTo(repo.coordinates().repo()));
}
Also used : MkGithub(com.jcabi.github.mock.MkGithub) Test(org.junit.Test)

Example 35 with MkGithub

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

the class RtBranchTest method fetchesRepo.

/**
 * RtBranch can fetch its repo.
 * @throws Exception if a problem occurs.
 */
@Test
public void fetchesRepo() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final Coordinates coords = RtBranchTest.newBranch(repo).repo().coordinates();
    MatcherAssert.assertThat(coords.user(), Matchers.equalTo(repo.coordinates().user()));
    MatcherAssert.assertThat(coords.repo(), Matchers.equalTo(repo.coordinates().repo()));
}
Also used : MkGithub(com.jcabi.github.mock.MkGithub) 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