Package javax.json

Examples of javax.json.JsonObject


        ).start();
        final Commits commits = new RtCommits(
            new ApacheRequest(container.home()),
            repo()
        );
        final JsonObject author = Json.createObjectBuilder()
            .add("name", "Scott").add("email", "scott@gmail.com")
            .add("date", "2011-06-17T14:53:35-07:00").build();
        final JsonObject input = Json.createObjectBuilder()
            .add("message", "initial version")
            .add("author", author).build();
        try {
            final Commit newCommit = commits.create(input);
            MatcherAssert.assertThat(
View Full Code Here


        ).start();
        final Tags tags = new RtTags(
            new ApacheRequest(container.home()),
            repo()
        );
        final JsonObject tagger = Json.createObjectBuilder()
            .add("name", "Scott").add("email", "scott@gmail.com")
            .add("date", "2011-06-17T14:53:35-07:00").build();
        final JsonObject input = Json.createObjectBuilder()
            .add("tag", "v.0.1").add("message", "initial version")
            .add("object", "07cd4r45Test444").add("type", "commit")
            .add("tagger", tagger).build();
        try {
            MatcherAssert.assertThat(
View Full Code Here

     *
     * @throws Exception if a problem occurs
     */
    @Test
    public void canSearchForContents() throws Exception {
        final JsonObject first = RtSearchTest.content(
            "test/unit/attributes.js",
            "attributes.js",
            // @checkstyle LineLength (1 line)
            "https://api.github.com/repos/user/repo/contents/test/unit/attributes.js?ref=f3b89ba0820882bd4ce4404b7e7c819e7b506de5"
        ).build();
        final JsonObject second = RtSearchTest.content(
            "src/attributes/classes.js",
            "classes.js",
            // @checkstyle LineLength (1 line)
            "https://api.github.com/repos/user/repo/contents/src/attributes/classes.js?ref=f3b89ba0820882bd4ce4404b7e7c819e7b506de5"
        ).build();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(RtSearchTest.search(first, second).toString())
        ).next(new MkAnswer.Simple(first.toString()))
            .next(new MkAnswer.Simple(second.toString()))
            .start();
        try {
            final Search search = new RtGithub(
                new ApacheRequest(container.home())
            ).search();
View Full Code Here

     * @throws Exception if some problem inside.
     */
    @Test
    public void canFetchReadmeFile() throws Exception {
        final String path = "README.md";
        final JsonObject body = Json.createObjectBuilder()
            .add("path", path)
            .build();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body.toString())
        ).start();
        final RtContents contents = new RtContents(
            new ApacheRequest(container.home()),
            repo()
        );
View Full Code Here

     * @throws Exception if a problem occurs.
     */
    @Test
    public void canFetchReadmeFileFromSpecifiedBranch() throws Exception {
        final String path = "README.md";
        final JsonObject body = Json.createObjectBuilder()
            .add("path", path)
            .build();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body.toString())
        ).start();
        final RtContents contents = new RtContents(
            new ApacheRequest(container.home()),
            repo()
        );
View Full Code Here

     */
    @Test
    public void canFetchFilesFromRepository() throws Exception {
        final String path = "test/file";
        final String name = "file";
        final JsonObject body = Json.createObjectBuilder()
            .add("path", path)
            .add("name", name)
            .build();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                Json.createObjectBuilder()
                    .add("path", path)
                    .add("name", name)
                    .build().toString()
            )
        ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, body.toString()))
            .start();
        final RtContents contents = new RtContents(
            new ApacheRequest(container.home()),
            repo()
        );
View Full Code Here

     * @throws Exception If any problems during test execution occurs.
     */
    @Test
    public void canUpdateFilesInRepository() throws Exception {
        final String sha = "2f97253a513bbe26658881c29e27910082fef900";
        final JsonObject resp = Json.createObjectBuilder()
            // @checkstyle MultipleStringLiterals (1 line)
            .add("sha", sha).build();
        final MkContainer container = new MkGrizzlyContainer().next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                Json.createObjectBuilder().add("commit", resp)
                    .build().toString()
            )
        ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, resp.toString()))
            .start();
        try {
            final RtContents contents = new RtContents(
                new ApacheRequest(container.home()),
                repo()
            );
            final String path = "test.txt";
            final JsonObject json = Json.createObjectBuilder()
                .add("message", "let's change it.")
                .add("content", "bmV3IHRlc3Q=")
                .add("sha", "90b67dda6d5944ad167e20ec52bfed8fd56986c8")
                .build();
            MatcherAssert.assertThat(
                new RepoCommit.Smart(contents.update(path, json)).sha(),
                Matchers.is(sha)
            );
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
                query.method(),
                Matchers.equalTo(Request.PUT)
            );
            MatcherAssert.assertThat(
                query.uri().getPath(),
                Matchers.endsWith(path)
            );
            MatcherAssert.assertThat(
                query.body(),
                Matchers.equalTo(json.toString())
            );
        } finally {
            container.stop();
        }
    }
View Full Code Here

        final Pull pull = Mockito.mock(Pull.class);
        Mockito.doReturn(repo()).when(pull).repo();
        final RtPullComment comment =
            new RtPullComment(new ApacheRequest(container.home()), pull, 1);
        try {
            final JsonObject json = comment.json();
            MatcherAssert.assertThat(
                json.getString("body"),
                Matchers.is("test")
            );
            MatcherAssert.assertThat(
                container.take().uri().toString(),
                Matchers.endsWith("/repos/joe/test/pulls/comments/1")
View Full Code Here

        final Pull pull = Mockito.mock(Pull.class);
        Mockito.doReturn(repo()).when(pull).repo();
        final RtPullComment comment =
            new RtPullComment(new ApacheRequest(container.home()), pull, 2);
        try {
            final JsonObject json = Json.createObjectBuilder()
                .add("body", "test comment").build();
            comment.patch(json);
            final MkQuery query = container.take();
            MatcherAssert.assertThat(
                query.method(), Matchers.equalTo(Request.PATCH)
View Full Code Here

        ).start();
        final Trees trees = new RtTrees(
            new ApacheRequest(container.home()),
            repo()
        );
        final JsonObject tree = Json.createObjectBuilder()
            .add("path", "/path").add("mode", "100644 ")
            .add("type", "blob").add("sha", "sha1")
            .add("content", "content1").build();
        final JsonObject input = Json.createObjectBuilder()
            .add("tree", tree).add("base_tree", "SHA1")
            .build();
        try {
            final Tree tri = trees.create(input);
            MatcherAssert.assertThat(
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.