Search in sources :

Example 1 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtPublicKeyTest method canObtainUser.

/**
 * RtPublicKey can obtain its own user.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canObtainUser() throws Exception {
    final User user = Mockito.mock(User.class);
    final RtPublicKey key = new RtPublicKey(new FakeRequest(), user, 2);
    MatcherAssert.assertThat(key.user(), Matchers.sameInstance(user));
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 2 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtPublicMembersTest method fetchesOrg.

/**
 * RtPublicMembers can fetch its organization.
 * @throws IOException If there is an I/O problem
 */
@Test
public void fetchesOrg() throws IOException {
    final Organization org = organization();
    MatcherAssert.assertThat(new RtPublicMembers(new FakeRequest(), org).org(), Matchers.equalTo(org));
}
Also used : MkOrganization(com.jcabi.github.mock.MkOrganization) FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 3 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtPullCommentsTest method fetchesPullComment.

/**
 * RtPullComments can fetch a single comment.
 *
 * @throws Exception If something goes wrong.
 */
@Test
public void fetchesPullComment() throws Exception {
    final Pull pull = Mockito.mock(Pull.class);
    Mockito.doReturn(repo()).when(pull).repo();
    final RtPullComments comments = new RtPullComments(new FakeRequest(), pull);
    MatcherAssert.assertThat(comments.get(1), Matchers.notNullValue());
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 4 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtReleaseAssetTest method canObtainOwnRelease.

/**
 * RtReleaseAsset can obtain its own release.
 * @throws Exception if a problem occurs.
 */
@Test
public void canObtainOwnRelease() throws Exception {
    final Release release = release();
    final RtReleaseAsset asset = new RtReleaseAsset(new FakeRequest(), release, 1);
    MatcherAssert.assertThat(asset.release(), Matchers.is(release));
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 5 with FakeRequest

use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.

the class RtReleaseAssetsTest method uploadReleaseAsset.

/**
 * RtRelease can upload a release asset.
 *
 * @throws Exception If something goes wrong
 */
@Test
public void uploadReleaseAsset() throws Exception {
    final String body = "{\"id\":1}";
    final ReleaseAssets assets = new RtReleaseAssets(new FakeRequest().withStatus(HttpURLConnection.HTTP_CREATED).withBody(body), release());
    MatcherAssert.assertThat(assets.upload(body.getBytes(), "text/plain", "hello.txt").number(), Matchers.is(1));
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Aggregations

FakeRequest (com.jcabi.http.request.FakeRequest)65 Test (org.junit.Test)65 MkGithub (com.jcabi.github.mock.MkGithub)9 JsonObject (javax.json.JsonObject)3 Request (com.jcabi.http.Request)2 ApacheRequest (com.jcabi.http.request.ApacheRequest)2 MkOrganization (com.jcabi.github.mock.MkOrganization)1 Response (com.jcabi.http.Response)1 MkContainer (com.jcabi.http.mock.MkContainer)1 MkGrizzlyContainer (com.jcabi.http.mock.MkGrizzlyContainer)1 JsonResponse (com.jcabi.http.response.JsonResponse)1