use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtReleasesTest method canCreateRelease.
/**
* RtReleases can create a release.
* @throws Exception If some problem inside
*/
@Test
public void canCreateRelease() throws Exception {
final String tag = "v1.0.0";
final String rel = release(tag).toString();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, rel)).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, rel)).start();
final RtReleases releases = new RtReleases(new JdkRequest(container.home()), repo());
final Release release = releases.create(tag);
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.POST));
MatcherAssert.assertThat(release.json().getString("tag_name"), Matchers.equalTo(tag));
container.stop();
}
use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtSearchTest method canSearchForContents.
/**
* RtSearch can search for contents.
*
* @throws Exception if a problem occurs
*/
@Test
public void canSearchForContents() throws Exception {
final JsonObject first = RtSearchTest.content("test/unit/attributes.js", "attributes.js", // @checkstyle LineLength (1 line)
"https://api.github.com/repos/user/repo/contents/test/unit/attributes.js?ref=f3b89ba0820882bd4ce4404b7e7c819e7b506de5").build();
final JsonObject second = RtSearchTest.content("src/attributes/classes.js", "classes.js", // @checkstyle LineLength (1 line)
"https://api.github.com/repos/user/repo/contents/src/attributes/classes.js?ref=f3b89ba0820882bd4ce4404b7e7c819e7b506de5").build();
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(RtSearchTest.search(first, second).toString())).next(new MkAnswer.Simple(first.toString())).next(new MkAnswer.Simple(second.toString())).start();
try {
final Search search = new RtGithub(new ApacheRequest(container.home())).search();
MatcherAssert.assertThat(search.codes("test4", "joined", Search.Order.DESC), Matchers.<Content>iterableWithSize(2));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtRepoTest method iteratesEvents.
/**
* RtRepo can fetch events.
*
* @throws Exception If some problem inside
*/
@Test
public void iteratesEvents() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createArrayBuilder().add(event(Event.ASSIGNED)).add(event(Event.MENTIONED)).build().toString())).start();
final Repo repo = RtRepoTest.repo(new ApacheRequest(container.home()));
MatcherAssert.assertThat(repo.issueEvents().iterate(), Matchers.<Event>iterableWithSize(2));
container.stop();
}
use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtRepoTest method iteratesLanguages.
/**
* RtRepo can iterate languages.
*
* @throws Exception If some problem inside
*/
@Test
public void iteratesLanguages() throws Exception {
final String lang = "C";
final String other = "Java";
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, Json.createObjectBuilder().add(lang, 1).add(other, 2).build().toString())).start();
final Repo repo = RtRepoTest.repo(new ApacheRequest(container.home()));
try {
final Iterator<Language> iter = repo.languages().iterator();
MatcherAssert.assertThat(iter.hasNext(), Matchers.is(true));
MatcherAssert.assertThat(iter.next().name(), Matchers.is(lang));
MatcherAssert.assertThat(iter.hasNext(), Matchers.is(true));
MatcherAssert.assertThat(iter.next().name(), Matchers.is(other));
MatcherAssert.assertThat(iter.hasNext(), Matchers.is(false));
} finally {
container.stop();
}
}
use of com.jcabi.http.mock.MkContainer in project jcabi-github by jcabi.
the class RtReposTest method removeRepo.
/**
* RtRepos can remove a repo.
* @throws Exception if some problem inside
*/
@Test
public void removeRepo() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final Repos repos = new RtRepos(Mockito.mock(Github.class), new ApacheRequest(container.home()));
repos.remove(new Coordinates.Simple("", ""));
try {
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
MatcherAssert.assertThat(query.body(), Matchers.isEmptyString());
} finally {
container.stop();
}
}
Aggregations