use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.
the class BulkTest method cachesJsonData.
/**
* Bulk can cache JSON data.
* @throws Exception If some problem inside
*/
@Test
public void cachesJsonData() throws Exception {
final Comment origin = Mockito.mock(Comment.class);
final Request request = new FakeRequest().withBody("[{\"body\": \"hey you\"}]");
final Iterable<Comment> comments = new Bulk<Comment>(new RtPagination<Comment>(request, new RtValuePagination.Mapping<Comment, JsonObject>() {
@Override
public Comment map(final JsonObject object) {
return origin;
}
}));
final Comment comment = comments.iterator().next();
MatcherAssert.assertThat(new Comment.Smart(comment).body(), Matchers.equalTo("hey you"));
comment.number();
Mockito.verify(origin).number();
Mockito.verify(origin, Mockito.never()).json();
}
use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.
the class CommitsComparisonTest method fetchesCommits.
/**
* CommitsComparison.Smart can fetch commits.
* @throws Exception If some problem inside
*/
@Test
public void fetchesCommits() throws Exception {
final String sha = "6dcb09b5b57875f334f61aebed695e2e4193db50";
final CommitsComparison.Smart comparison = new CommitsComparison.Smart(new RtCommitsComparison(new FakeRequest().withBody(Json.createObjectBuilder().add("base_commit", Json.createObjectBuilder()).add("commits", Json.createArrayBuilder().add(Json.createObjectBuilder().add("sha", sha))).add("files", Json.createArrayBuilder()).build().toString()), CommitsComparisonTest.repo(), "6dcb09b5b57875f334f61aebed695e2e4193db51", "6dcb09b5b57875f334f61aebed695e2e4193db52"));
MatcherAssert.assertThat(comparison.commits().iterator().next().sha(), Matchers.equalTo(sha));
}
use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.
the class CommitsComparisonTest method fetchesFiles.
/**
* CommitsComparison.Smart can fetch files.
* @throws Exception If some problem inside
*/
@Test
public void fetchesFiles() throws Exception {
final String filename = "file.txt";
final CommitsComparison.Smart comparison = new CommitsComparison.Smart(new RtCommitsComparison(new FakeRequest().withBody(Json.createObjectBuilder().add("base_commit", Json.createObjectBuilder()).add("commits", Json.createArrayBuilder()).add("files", Json.createArrayBuilder().add(Json.createObjectBuilder().add("filename", filename))).build().toString()), CommitsComparisonTest.repo(), "6dcb09b5b57875f334f61aebed695e2e4193db53", "6dcb09b5b57875f334f61aebed695e2e4193db54"));
MatcherAssert.assertThat(new FileChange.Smart(comparison.files().iterator().next()).filename(), Matchers.equalTo(filename));
}
use of com.jcabi.http.request.FakeRequest 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));
}
use of com.jcabi.http.request.FakeRequest in project jcabi-github by jcabi.
the class RtPullCommentTest method canCompareInstances.
/**
* RtPullComment should be able to compare different instances.
* @throws Exception If a problem occurs.
*/
@Test
public void canCompareInstances() throws Exception {
final Pull pull = Mockito.mock(Pull.class);
Mockito.doReturn(new MkGithub().randomRepo()).when(pull).repo();
final RtPullComment less = new RtPullComment(new FakeRequest(), pull, 1);
final RtPullComment greater = new RtPullComment(new FakeRequest(), pull, 2);
MatcherAssert.assertThat(less.compareTo(greater), Matchers.lessThan(0));
MatcherAssert.assertThat(greater.compareTo(less), Matchers.greaterThan(0));
MatcherAssert.assertThat(less.compareTo(less), Matchers.equalTo(0));
}
Aggregations