Package javax.json

Examples of javax.json.JsonObject


    @Test
    public void testJSON() {
        Response response = getResource(resourceURL, APPLICATION_JSON_TYPE);

        JsonObject content = response.readEntity(JsonObject.class);
        System.out.println(content);

        assertTrue(content.containsKey("result"));
        assertEquals("Hello World!", content.getString("result"));
    }
View Full Code Here


    @NotNull(message = "reference is never NULL")
    public Reference create(
        @NotNull(message = "ref can't be NULL") final String ref,
        @NotNull(message = "sha can't be NULL") final String sha
    ) throws IOException {
        final JsonObject json = Json.createObjectBuilder()
            .add("sha", sha).add(RtReferences.REF, ref).build();
        return this.get(
            this.request.method(Request.POST)
                .body().set(json).back()
                .fetch().as(RestResponse.class)
View Full Code Here

     * Return a Tag for testing.
     * @return Tag
     * @throws Exception If something goes wrong.
     */
    private Tag tag() throws Exception {
        final JsonObject json = Json.createObjectBuilder()
            .add("sha", "abcsha12").add("message", "test tag")
            .add("name", "v.0.1").build();
        return new MkGithub().repos().create(
            Json.createObjectBuilder().add("name", "test").build()
        ).git().tags().create(json);
View Full Code Here

    @Test
    public void canRemoveFile() throws Exception {
        final Repo repo = MkContentsTest.repo();
        final String path = "removeme.txt";
        this.createFile(repo, path);
        final JsonObject json = MkContentsTest
            .content(path, "theDeleteMessage")
            .add("committer", MkContentsTest.committer())
            .build();
        final RepoCommit commit = repo.contents().remove(json);
        MatcherAssert.assertThat(commit, Matchers.notNullValue());
View Full Code Here

    public void canRemoveFileFromBranch() throws Exception {
        final String branch = "branch-1";
        final Repo repo = MkContentsTest.repo();
        final String path = "removeme.txt";
        this.createFile(repo, path);
        final JsonObject json = MkContentsTest
            .content(path, "theDeleteMessage")
            .add("ref", branch)
            .add("committer", MkContentsTest.committer())
            .build();
        final RepoCommit commit = repo.contents().remove(json);
View Full Code Here

    @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())
View Full Code Here

        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(),
View Full Code Here

    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)
View Full Code Here

     * @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

         * @return File names
         * @throws IOException If there is any I/O problem
         */
        @NotNull(message = "Iterable of files is never NULL")
        public Iterable<String> files() throws IOException {
            final JsonObject array = this.gist.json().getJsonObject("files");
            final Collection<String> files =
                new ArrayList<String>(array.size());
            for (final JsonValue value : array.values()) {
                files.add(JsonObject.class.cast(value).getString("filename"));
            }
            return files;
        }
View Full Code Here

TOP

Related Classes of javax.json.JsonObject

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.