Search in sources :

Example 41 with MkGithub

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

the class RtForkTest method patchAndCheckJsonFork.

/**
 * RtFork can patch comment and return new json.
 * @throws IOException if has some problems with json parsing.
 */
@Test
public void patchAndCheckJsonFork() throws IOException {
    final String original = "some organization";
    final String patched = "some patched organization";
    final MkContainer container = new MkGrizzlyContainer().next(this.answer(original)).next(this.answer(patched)).next(this.answer(original)).start(this.resource.port());
    final MkContainer forksContainer = new MkGrizzlyContainer().start(this.resource.port());
    final RtRepo repo = new RtRepo(new MkGithub(), new ApacheRequest(forksContainer.home()), new Coordinates.Simple("test_user", "test_repo"));
    final RtFork fork = new RtFork(new ApacheRequest(container.home()), repo, 1);
    fork.patch(RtForkTest.fork(patched));
    MatcherAssert.assertThat(new Fork.Smart(fork).organization(), Matchers.equalTo(patched));
    MatcherAssert.assertThat(new Fork.Smart(fork).name(), Matchers.notNullValue());
    container.stop();
    forksContainer.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 42 with MkGithub

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

the class PullRefTest method fetchesRepo.

/**
 * PullRef.Smart 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(PullRefTest.pullRef(repo).repo().coordinates(), Matchers.equalTo(repo.coordinates()));
}
Also used : MkGithub(com.jcabi.github.mock.MkGithub) Test(org.junit.Test)

Example 43 with MkGithub

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

the class PullRefTest method fetchesUser.

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

Example 44 with MkGithub

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

the class RtOrganizationTest method patchWithJson.

/**
 * RtOrganization should be able to perform a patch request.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void patchWithJson() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "response")).start();
    final RtOrganization org = new RtOrganization(new MkGithub(), new ApacheRequest(container.home()), "testPatch");
    org.patch(Json.createObjectBuilder().add("patch", "test").build());
    final MkQuery query = container.take();
    try {
        MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.PATCH));
        MatcherAssert.assertThat(query.body(), Matchers.equalTo("{\"patch\":\"test\"}"));
    } finally {
        container.stop();
    }
}
Also used : MkGrizzlyContainer(com.jcabi.http.mock.MkGrizzlyContainer) ApacheRequest(com.jcabi.http.request.ApacheRequest) MkQuery(com.jcabi.http.mock.MkQuery) MkGithub(com.jcabi.github.mock.MkGithub) MkContainer(com.jcabi.http.mock.MkContainer) Test(org.junit.Test)

Example 45 with MkGithub

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

the class RtOrganizationTest method canCompareInstances.

/**
 * RtOrganization should be able to compare instances of each other.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canCompareInstances() throws Exception {
    final RtOrganization less = new RtOrganization(new MkGithub(), new FakeRequest(), "abc");
    final RtOrganization greater = new RtOrganization(new MkGithub(), new FakeRequest(), "def");
    MatcherAssert.assertThat(less.compareTo(greater), Matchers.lessThan(0));
    MatcherAssert.assertThat(greater.compareTo(less), Matchers.greaterThan(0));
    MatcherAssert.assertThat(less.compareTo(less), Matchers.equalTo(0));
}
Also used : MkGithub(com.jcabi.github.mock.MkGithub) FakeRequest(com.jcabi.http.request.FakeRequest) 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