* @throws IOException If there is a problem.
*/
@Test
public void fork() throws IOException {
final String fileContent = "success";
final MkContainer container = new MkGrizzlyContainer();
container.next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
"{\"files\":{\"hello\":{\"raw_url\":\"world\"}}}"
)
);
container.next(
new MkAnswer.Simple(HttpURLConnection.HTTP_OK, fileContent)
);
container.next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_CREATED,
"{\"id\": \"forked\"}"
)
);
container.next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
"{\"files\":{\"hello\":{\"raw_url\":\"world\"}}}"
)
);
container.next(
new MkAnswer.Simple(HttpURLConnection.HTTP_OK, fileContent)
);
container.start();
final Gist gist = new RtGist(
new MkGithub(),
new ApacheRequest(container.home()),
"test"
);
final String content = gist.read("hello");
final Gist forkedGist = gist.fork();
try {
MatcherAssert.assertThat(
forkedGist.read("hello"),
Matchers.equalTo(content)
);
} finally {
container.stop();
}
}