use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtMarkdownTest method returnsRawOutput.
/**
* RtMarkdown should be able to return raw output.
*
* @throws Exception If a problem occurs.
*/
@Test
public void returnsRawOutput() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "Test Output").withHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML)).start(this.resource.port());
final RtMarkdown markdown = new RtMarkdown(new MkGithub(), new ApacheRequest(container.home()));
try {
MatcherAssert.assertThat(markdown.raw("Hello World!"), Matchers.equalTo("Test Output"));
MatcherAssert.assertThat(container.take().body(), Matchers.equalTo("Hello World!"));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCollaboratorsTest method repo.
/**
* Create and return repo for testing.
* @return Repo
* @throws Exception If some problem inside
*/
private Repo repo() throws Exception {
final Repo repo = Mockito.mock(Repo.class);
Mockito.doReturn(new Coordinates.Simple("test", "collaboratorrepo")).when(repo).coordinates();
Mockito.doReturn(new MkGithub(new MkStorage.InFile(), "userLogin")).when(repo).github();
return repo;
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtCommitTest method readsMessage.
/**
* Commit.Smart can read message.
* @throws Exception when an error occurs
*/
@Test
public final void readsMessage() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"sha\":\"a0b1c3\",\"commit\":{\"message\":\"hello\"}}")).start(this.resource.port());
try {
final Commit.Smart commit = new Commit.Smart(new RtCommit(new JdkRequest(container.home()), new MkGithub().randomRepo(), "sha"));
MatcherAssert.assertThat(commit.message(), Matchers.equalTo("hello"));
} finally {
container.stop();
}
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtGistTest method canUnstarAGist.
/**
* RtGist can unstar a starred Gist.
* @throws Exception If something goes wrong.
*/
@Test
public void canUnstarAGist() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")).start();
final RtGist gist = new RtGist(new MkGithub(), new ApacheRequest(container.home()), "unstar");
gist.unstar();
final MkQuery query = container.take();
MatcherAssert.assertThat(query.method(), Matchers.equalTo(Request.DELETE));
MatcherAssert.assertThat(query.body(), Matchers.isEmptyOrNullString());
container.stop();
}
use of com.jcabi.github.mock.MkGithub in project jcabi-github by jcabi.
the class RtGistTest method executePatchRequest.
/**
* RtGist can execute PATCH request.
*
* @throws Exception if there is any problem
*/
@Test
public void executePatchRequest() throws Exception {
final MkContainer container = new MkGrizzlyContainer().next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"msg\":\"hi\"}")).start();
try {
final RtGist gist = new RtGist(new MkGithub(), new ApacheRequest(container.home()), "patch");
gist.patch(Json.createObjectBuilder().add("content", "hi you!").build());
MatcherAssert.assertThat(container.take().method(), Matchers.equalTo(Request.PATCH));
} finally {
container.stop();
}
}
Aggregations