Package com.jcabi.github

Examples of com.jcabi.github.Contents


     * MkContents can fetch the default branch readme file.
     * @throws Exception if some problem inside
     */
    @Test
    public void canFetchReadmeFile() throws Exception {
        final Contents contents = MkContentsTest.repo().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)
        );
    }
View Full Code Here


     * @throws Exception if some problem inside
     */
    @Test
    public void canFetchReadmeFromBranch() throws Exception {
        final String branch = "branch-1";
        final Contents contents = MkContentsTest.repo().contents();
        final String body = "Readme On Branch";
        contents.create(
            content("README.md", "readme on branch", body)
                .add("ref", branch)
                .build()
        );
        MatcherAssert.assertThat(
            contents.readme(branch).json().getString("content"),
            Matchers.is(body)
        );
    }
View Full Code Here

        final String path = "file.txt";
        final String message = "content message";
        final String initial = "initial text";
        final String updated = "updated text";
        final String cont = "content";
        final Contents contents = MkContentsTest.repo().contents();
        MatcherAssert.assertThat(
            contents.create(
                MkContentsTest.content(path, message, initial).build()
            ).json().getString(cont),
            Matchers.is(initial)
        );
        contents.update(
            path, MkContentsTest.content(path, message, updated).build()
        );
        MatcherAssert.assertThat(
            contents.get(path, "master").json().getString(cont),
            Matchers.is(updated)
        );
    }
View Full Code Here

     * @throws Exception Exception if some problem inside
     */
    @Test
    public void updatesFileCreateCommit() throws Exception {
        final MkStorage storage = new MkStorage.InFile();
        final Contents contents = MkContentsTest.repo(storage).contents();
        final String path = "file.txt";
        final JsonObject json = MkContentsTest
            .content(path, "theCreateMessage", "newContent")
            .add("committer", MkContentsTest.committer())
            .build();
        contents.create(json);
        final String xpath = "/github/repos/repo/commits/commit";
        MatcherAssert.assertThat(
            storage.xml().nodes(xpath),
            Matchers.<XML>iterableWithSize(1)
        );
        final JsonObject update = MkContentsTest
            .content(path, "theMessage", "blah")
            .build();
        MatcherAssert.assertThat(
            new RepoCommit.Smart(contents.update(path, update)).sha(),
            Matchers.not(Matchers.isEmptyOrNullString())
        );
        MatcherAssert.assertThat(
            new Content.Smart(contents.get(path, "master")).path(),
            Matchers.is(path)
        );
        MatcherAssert.assertThat(
            storage.xml().nodes(xpath),
            Matchers.<XML>iterableWithSize(2)
View Full Code Here

        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 = MkContentsTest.repo().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)
        );
    }
View Full Code Here

     */
    @Test
    public void checkExists() throws Exception {
        final String path = "content-exist.txt";
        final String branch = "rel.08";
        final Contents contents = MkContentsTest.repo().contents();
        contents.create(
            MkContentsTest.content(path, "commit", "content exists")
                .add("ref", branch)
                .build()
        );
        MatcherAssert.assertThat(
            contents.exists(path, branch),
            Matchers.is(true)
        );
        MatcherAssert.assertThat(
            contents.exists("content-not-exist.txt", branch),
            Matchers.is(false)
        );
    }
View Full Code Here

    @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 = MkContentsTest.repo().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)
        );
    }
View Full Code Here

     * @return Created content
     * @throws Exception if some problem inside
     */
    private Content createFile(
        final Repo repo, final String path) throws Exception {
        final Contents contents = repo.contents();
        final JsonObject json = MkContentsTest
            .content(path, "theCreateMessage", "newContent")
            .add("committer", MkContentsTest.committer())
            .build();
        return contents.create(json);
    }
View Full Code Here

     * @throws Exception if some problem inside
     */
    @Test
    public void canGetOwnRepo() throws Exception {
        final Repo repo = MkContentTest.repo();
        final Contents contents = repo.contents();
        final Content content = contents.create(
            jsonContent("repo.txt", "for repo", "json repo")
        );
        MatcherAssert.assertThat(
            content.repo(),
            Matchers.is(repo)
View Full Code Here

     *
     * @throws Exception if some problem inside
     */
    @Test
    public void canGetOwnPath() throws Exception {
        final Contents contents = MkContentTest.repo().contents();
        final String path = "dummy.txt";
        final Content content = contents.create(
            jsonContent(path, "for path", "path test")
        );
        MatcherAssert.assertThat(
            content.path(),
            Matchers.is(path)
View Full Code Here

TOP

Related Classes of com.jcabi.github.Contents

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.