Package javax.json

Examples of javax.json.JsonObject


    @Test
    public void convertsXmlToJson() throws Exception {
        final XML xml = new XMLDocument(
            "<user><name>Jeff</name><dept><title>IT</title></dept></user>"
        );
        final JsonObject json = new JsonNode(xml.nodes("user").get(0)).json();
        MatcherAssert.assertThat(json, Matchers.notNullValue());
        MatcherAssert.assertThat(
            json.getString("name"),
            Matchers.equalTo("Jeff")
        );
        MatcherAssert.assertThat(
            json.getJsonObject("dept").getString("title"),
            Matchers.equalTo("IT")
        );
    }
View Full Code Here


    }

    @Override
    @NotNull(message = "JSON is never NULL")
    public JsonObject json() throws IOException {
        final JsonObject obj = new JsonNode(
            this.storage.xml().nodes(this.xpath()).get(0)
        ).json();
        final JsonObjectBuilder json = Json.createObjectBuilder();
        for (final Map.Entry<String, JsonValue> val: obj.entrySet()) {
            json.add(val.getKey(), val.getValue());
        }
        final JsonArrayBuilder array = Json.createArrayBuilder();
        for (final Label label : this.labels().iterate()) {
            array.add(
View Full Code Here

     */
    @Test
    public void canRetrieveAsJson() throws Exception {
        final String title = "Title1";
        final String key = "PublicKey1";
        final JsonObject json = new MkGithub().users().get("john").keys()
            .create(title, key).json();
        MatcherAssert.assertThat(
            json.getString("id"),
            Matchers.equalTo("1")
        );
        MatcherAssert.assertThat(
            json.getString("title"),
            Matchers.equalTo(title)
        );
        MatcherAssert.assertThat(
            json.getString(KEY),
            Matchers.equalTo(key)
        );
    }
View Full Code Here

     * MkTags can create tags.
     * @throws Exception If something goes wrong.
     */
    @Test
    public void createsMkTag() throws Exception {
        final JsonObject tagger = Json.createObjectBuilder()
            .add("name", "Scott").add("email", "Scott@gmail.com").build();
        MatcherAssert.assertThat(
            this.repo().git().tags().create(
                Json.createObjectBuilder().add("name", "v.0.1")
                    .add("message", "test tag").add("sha", "abcsha12")
View Full Code Here

     * MkTrees can create trees.
     * @throws Exception If something goes wrong.
     */
    @Test
    public void createsMkTree() throws Exception {
        final JsonObject tree = Json.createObjectBuilder()
            .add("base_tree", "base_tree_sha")
            .add(
                "tree",
                Json.createArrayBuilder().add(
                    Json.createObjectBuilder()
View Full Code Here

     * @throws Exception if some problem inside
     */
    @Test
    public void getTreeRec() throws Exception {
        final String sha = "0abcd89jcabitest";
        final JsonObject json = Json.createObjectBuilder().add(
            "tree",
            Json.createArrayBuilder().add(
                Json.createObjectBuilder()
                    .add("path", "test.txt")
                    .add("mode", "100644")
View Full Code Here

     * @throws Exception - If something goes wrong.
     */
    @Test
    public void fetchesJson() throws Exception {
        final Reference ref = this.reference();
        final JsonObject json = ref.json();
        MatcherAssert.assertThat(
            json.getString("ref"),
            Matchers.is("refs/tags/hello")
        );
        MatcherAssert.assertThat(
            json.getString("sha"),
            Matchers.is("testsha")
        );
    }
View Full Code Here

     * @throws Exception - If something goes wrong.
     */
    @Test
    public void patchesRef() throws Exception {
        final Reference ref = this.reference();
        final JsonObject json = Json.createObjectBuilder()
            .add("sha", "testshaPATCH")
            .build();
        ref.patch(json);
        MatcherAssert.assertThat(
            ref.json().getString("sha"),
View Full Code Here

        final int comment
    )
        throws IOException {
        this.storage.lock();
        try {
            final JsonObject orig = this.get(comment).json();
            final PullComment reply = this.post(
                body,
                orig.getString("commit_id"),
                orig.getString("path"),
                comment
            );
            reply.patch(
                Json.createObjectBuilder()
                    .add("original_position", String.valueOf(comment)).build()
View Full Code Here

            "6dcb09b5b57875f334f61aebed695e2e4193db5e",
            "file1.txt",
            1
        ).number();
        final String body = "Reply Comment";
        final JsonObject reply = comments.reply(body, orig).json();
        MatcherAssert.assertThat(
            reply.getString("body"),
            Matchers.is(body)
        );
        MatcherAssert.assertThat(
            reply.getString("original_position"),
            Matchers.is(Integer.toString(orig))
        );
    }
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.