use of com.jcabi.github.Contents in project jcabi-github by jcabi.
the class MkContentTest method canGetOwnRepo.
/**
* MkContent should be able to fetch its own repo.
*
* @throws Exception if some problem inside
*/
@Test
public void canGetOwnRepo() throws Exception {
final Repo repo = new MkGithub().randomRepo();
final Contents contents = repo.contents();
final Content content = contents.create(jsonContent("repo.txt", "for repo", "json repo"));
MatcherAssert.assertThat(content.repo(), Matchers.is(repo));
}
use of com.jcabi.github.Contents in project jcabi-github by jcabi.
the class MkContentTest method fetchesRawRepresentation.
/**
* MkContent should be able to fetch its raw representation.
*
* @throws Exception if some problem inside
*/
@Test
public void fetchesRawRepresentation() throws Exception {
final Contents contents = new MkGithub().randomRepo().contents();
final String raw = "raw test \u20ac\u0000";
final InputStream stream = contents.create(jsonContent("raw.txt", "for raw", raw)).raw();
try {
MatcherAssert.assertThat(IOUtils.toString(stream, CharEncoding.UTF_8), Matchers.is(raw));
} finally {
stream.close();
}
}
use of com.jcabi.github.Contents in project jcabi-github by jcabi.
the class MkContentsTest method updateContent.
/**
* MkContents can update an content.
* @throws Exception if any problem inside
*/
@Test
public void updateContent() throws Exception {
final String path = "content-to-update.txt";
final String message = "commit message";
final String initial = "Hello World!";
final String updated = "update content";
final String branch = "master";
final Contents contents = new MkGithub().randomRepo().contents();
final JsonObject content = MkContentsTest.content(path, message, initial).add("ref", branch).build();
MatcherAssert.assertThat(new Content.Smart(contents.create(content)).content(), Matchers.is(initial));
contents.update(path, MkContentsTest.content(path, message, updated).add("ref", branch).build());
MatcherAssert.assertThat(new Content.Smart(contents.get(path, branch)).content(), Matchers.is(updated));
}
use of com.jcabi.github.Contents in project jcabi-github by jcabi.
the class MkContentsTest method getContentFromDefaultBranch.
/**
* MkContents can get content from default branch.
* @throws Exception if any problem inside
*/
@Test
public void getContentFromDefaultBranch() throws Exception {
final String path = "content-default-branch.txt";
final String message = "content default branch created";
final String text = "I'm content of default branch";
final Contents contents = new MkGithub().randomRepo().contents();
final JsonObject content = MkContentsTest.content(path, message, text).build();
MatcherAssert.assertThat(new Content.Smart(contents.create(content)).content(), Matchers.is(text));
MatcherAssert.assertThat(new Content.Smart(contents.get(path)).content(), Matchers.is(text));
}
use of com.jcabi.github.Contents in project jcabi-github by jcabi.
the class MkContentsTest method canFetchReadmeFile.
/**
* MkContents can fetch the default branch readme file.
* @throws Exception if some problem inside
*/
@Test
public void canFetchReadmeFile() throws Exception {
final Contents contents = new MkGithub().randomRepo().contents();
final String body = "Readme On Master";
// @checkstyle MultipleStringLiterals (6 lines)
contents.create(content("README.md", "readme on master", body).build());
MatcherAssert.assertThat(contents.readme().json().getString("content"), Matchers.is(body));
}
Aggregations