use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtGistsTest method canCreateFiles.
/**
* RtGists can create new files.
*
* @throws Exception if a problem occurs.
*/
@Test
public void canCreateFiles() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, "{\"id\":\"1\"}")).start(this.resource.port());
final Gists gists = new RtGists(new MkGithub(), new ApacheRequest(container.home()));
try {
MatcherAssert.assertThat(gists.create(Collections.singletonMap("test", ""), false), Matchers.notNullValue());
MatcherAssert.assertThat(container.take().body(), Matchers.startsWith("{\"files\":{\"test\":{\"content\":"));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtGistsTest method canIterateThrouRtGists.
/**
* RtGists can iterate through its contents.
*
* @throws Exception if a problem occurs.
*/
@Test
public void canIterateThrouRtGists() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "[{\"id\":\"hello\"}]")).start(this.resource.port());
final Gists gists = new RtGists(new MkGithub(), new ApacheRequest(container.home()));
try {
MatcherAssert.assertThat(gists.iterate().iterator().next(), Matchers.notNullValue());
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtGistsTest method canRetrieveSpecificGist.
/**
* RtGists can retrieve a specific Gist.
*
* @throws Exception if a problem occurs.
*/
@Test
public void canRetrieveSpecificGist() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "testing")).start(this.resource.port());
final Gists gists = new RtGists(new MkGithub(), new ApacheRequest(container.home()));
try {
MatcherAssert.assertThat(gists.get("gist"), Matchers.notNullValue());
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtBranchTest method fetchesCommit.
/**
* RtBranch can fetch its commit.
* @throws Exception if a problem occurs.
*/
@Test
public void fetchesCommit() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Commit commit = RtBranchTest.newBranch(repo).commit();
MatcherAssert.assertThat(commit.sha(), Matchers.equalTo(SHA));
final Coordinates coords = commit.repo().coordinates();
MatcherAssert.assertThat(coords.user(), Matchers.equalTo(repo.coordinates().user()));
MatcherAssert.assertThat(coords.repo(), Matchers.equalTo(repo.coordinates().repo()));
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtBranchTest method fetchesRepo.
/**
* RtBranch can fetch its repo.
* @throws Exception if a problem occurs.
*/
@Test
public void fetchesRepo() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Coordinates coords = RtBranchTest.newBranch(repo).repo().coordinates();
MatcherAssert.assertThat(coords.user(), Matchers.equalTo(repo.coordinates().user()));
MatcherAssert.assertThat(coords.repo(), Matchers.equalTo(repo.coordinates().repo()));
}
Aggregations