Search in sources :

Example 31 with FakeRequest

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

the class RtCommentTest method canCompareInstances.

/**
 * RtComment should be able to compare different instances.
 * @throws Exception when a problem occurs.
 */
@Test
public void canCompareInstances() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final Issue issue = repo.issues().create("title", "body");
    final RtComment less = new RtComment(new FakeRequest(), issue, 1);
    final RtComment greater = new RtComment(new FakeRequest(), issue, 2);
    MatcherAssert.assertThat(less.compareTo(greater), Matchers.lessThan(0));
    MatcherAssert.assertThat(greater.compareTo(less), Matchers.greaterThan(0));
}
Also used : MkGithub(com.jcabi.github.mock.MkGithub) FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 32 with FakeRequest

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

the class RtEventTest method canRetrieveOwnRepo.

/**
 * RtEvent can retrieve its own repo.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canRetrieveOwnRepo() throws Exception {
    final Repo repo = this.repo();
    final RtEvent event = new RtEvent(new FakeRequest(), repo, 1);
    MatcherAssert.assertThat(event.repo(), Matchers.sameInstance(repo));
}
Also used : FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 33 with FakeRequest

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

the class IssueTest method fetchLabelsRO.

/**
 * Issue.Smart can fetch issue's labels in read-only mode.
 * @throws IOException If some problem inside.
 */
@Test
public void fetchLabelsRO() throws IOException {
    final String name = "bug";
    final JsonObject json = Json.createObjectBuilder().add("labels", Json.createArrayBuilder().add(Json.createObjectBuilder().add("name", name).add("color", "f29513"))).build();
    final Issue issue = new RtIssue(new FakeRequest().withBody(json.toString()), this.repo(), 1);
    final IssueLabels labels = new Issue.Smart(issue).roLabels();
    this.thrown.expect(UnsupportedOperationException.class);
    labels.add(new ArrayList<String>(0));
    this.thrown.expect(UnsupportedOperationException.class);
    labels.replace(new ArrayList<String>(0));
    this.thrown.expect(UnsupportedOperationException.class);
    labels.remove(name);
    this.thrown.expect(UnsupportedOperationException.class);
    labels.clear();
    final Label label = labels.iterate().iterator().next();
    MatcherAssert.assertThat(label, Matchers.notNullValue());
    this.thrown.expect(UnsupportedOperationException.class);
    label.patch(Mockito.mock(JsonObject.class));
}
Also used : JsonObject(javax.json.JsonObject) FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 34 with FakeRequest

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

the class RtGistCommentTest method removeGistComment.

/**
 * RtGistComment can remove comment.
 * @throws IOException if has some problems with json parsing.
 */
@Test
public final void removeGistComment() throws IOException {
    final int identifier = 1;
    final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start(this.resource.port());
    final RtGist gist = new RtGist(new MkGithub(), new FakeRequest().withStatus(HttpURLConnection.HTTP_NO_CONTENT), "gistName");
    final RtGistComment comment = new RtGistComment(new ApacheRequest(container.home()), gist, identifier);
    comment.remove();
    MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.DELETE));
    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) FakeRequest(com.jcabi.http.request.FakeRequest) Test(org.junit.Test)

Example 35 with FakeRequest

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

the class RtIssueTest method canCompareInstances.

/**
 * RtIssue should be able to compare different instances.
 *
 * @throws Exception when a problem occurs.
 */
@Test
public void canCompareInstances() throws Exception {
    final RtIssue less = new RtIssue(new FakeRequest(), this.repo(), 1);
    final RtIssue greater = new RtIssue(new FakeRequest(), this.repo(), 2);
    MatcherAssert.assertThat(less.compareTo(greater), Matchers.lessThan(0));
    MatcherAssert.assertThat(greater.compareTo(less), Matchers.greaterThan(0));
}
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