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));
}
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));
}
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));
}
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();
}
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));
}
Aggregations