Package facebook4j.internal.org.json

Examples of facebook4j.internal.org.json.JSONArray


            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        List<Permission> permissions = new ArrayList<Permission>();
        JSONObject json = res.asJSONObject();
        try {
            JSONArray list = json.getJSONArray("data");
            for (int i = 0; i < list.length(); i++) {
                JSONObject permissionJSONObject = list.getJSONObject(i);
                Iterator<String> permissionNames = permissionJSONObject.keys();
                while (permissionNames.hasNext()) {
                    String permissionName = permissionNames.next();
                    boolean isGranted = getFlag(permissionName, permissionJSONObject);
                    permissions.add(new PermissionJSONImpl(permissionName, isGranted));
View Full Code Here


                if (responseAsString.startsWith("{")) {
                    JSONObject jsonObject = res.asJSONObject();
                    json = jsonObject.toString(4);
                } else
                if (responseAsString.startsWith("[")) {
                    JSONArray jsonArray = res.asJSONArray();
                    json = jsonArray.toString(4);
                } else {
                    json = responseAsString;
                }
                registerMockJSON(json);
            } catch (IOException e) {
View Full Code Here

        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Game> games = new ResponseListImpl<Game>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject gameJSONObject = list.getJSONObject(i);
                Game game = new GameJSONImpl(gameJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(game, gameJSONObject);
                }
                games.add(game);
View Full Code Here

                achievement = new AchievementJSONImpl.AchievedObjectJSONImpl(json.getJSONObject("achievement"));
            }
            if (!json.isNull("likes")) {
                JSONObject likesJSONObject = json.getJSONObject("likes");
                if (!likesJSONObject.isNull("data")) {
                    JSONArray list = likesJSONObject.getJSONArray("data");
                    final int size = list.length();
                    likes = new PagableListImpl<Like>(size, likesJSONObject);
                    for (int i = 0; i < size; i++) {
                        LikeJSONImpl like = new LikeJSONImpl(list.getJSONObject(i));
                        likes.add(like);
                    }
                } else {
                    likes = new PagableListImpl<Like>(1, likesJSONObject);
                }
            } else {
                likes = new PagableListImpl<Like>(0);
            }
            if (!json.isNull("comments")) {
                JSONObject commentsJSONObject = json.getJSONObject("comments");
                if (!commentsJSONObject.isNull("data")) {
                    JSONArray list = commentsJSONObject.getJSONArray("data");
                    final int size = list.length();
                    comments = new PagableListImpl<Comment>(size, commentsJSONObject);
                    for (int i = 0; i < size; i++) {
                        CommentJSONImpl comment = new CommentJSONImpl(list.getJSONObject(i));
                        comments.add(comment);
                    }
                } else {
                    comments = new PagableListImpl<Comment>(1, commentsJSONObject);
                }
View Full Code Here

        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Achievement> achievements = new ResponseListImpl<Achievement>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject achievementJSONObject = list.getJSONObject(i);
                Achievement achievement = new AchievementJSONImpl(achievementJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(achievement, achievementJSONObject);
                }
                achievements.add(achievement);
View Full Code Here

    public static class executeFQL extends MockFacebookTestBase {
        @Test
        public void friends() throws Exception {
            facebook.setMockJSON("mock_json/fql/friends.json");
            String query = "SELECT uid2 FROM friend WHERE uid1=me()";
            JSONArray actual = facebook.executeFQL(query);
            assertThat(facebook.getHttpMethod(), is(RequestMethod.GET));
            assertThat(facebook.getEndpointURL(), is(pathOf("/fql")));

            assertThat(actual.length(), is(3));
            for (int i = 0; i < actual.length(); i++) {
                JSONObject jsonObject = actual.getJSONObject(i);
                assertThat(jsonObject.getString("uid2"), is("10000000" + i));
            }
        }
View Full Code Here

        @Test
        public void locale() throws Exception {
            facebook.setMockJSON("mock_json/fql/uid_name.json");
            String query = "SELECT uid,name FROM user WHERE uid = me()";
            JSONArray actual = facebook.executeFQL(query, Locale.JAPAN);
            assertThat(facebook.getHttpMethod(), is(RequestMethod.GET));
            assertThat(facebook.getEndpointURL(), is(pathOf("/fql")));
            assertThat(facebook.getEndpointURL(), hasParameter("locale", "ja_JP"));

            assertThat(actual.length(), is(1));
            JSONObject jsonObject = actual.getJSONObject(0);
            assertThat(jsonObject.getString("uid"), is("1234567890123456"));
            assertThat(jsonObject.getString("name"), is("foo bar"));
        }
View Full Code Here

            Map<String, JSONArray> actuals = facebook.executeMultiFQL(queries);
            assertThat(facebook.getHttpMethod(), is(RequestMethod.GET));
            assertThat(facebook.getEndpointURL(), is(pathOf("/fql")));

            assertThat(actuals.size(), is(2));
            JSONArray actual1 = actuals.get("my_id");
            JSONObject jsonObject1 = actual1.getJSONObject(0);
            assertThat(jsonObject1.getString("uid"), is("1234567890123456"));
            JSONArray actual2 = actuals.get("my_name");
            JSONObject jsonObject2 = actual2.getJSONObject(0);
            assertThat(jsonObject2.getString("name"), is("foo bar"));
        }
View Full Code Here

            assertThat(facebook.getHttpMethod(), is(RequestMethod.GET));
            assertThat(facebook.getEndpointURL(), is(pathOf("/fql")));
            assertThat(facebook.getEndpointURL(), hasParameter("locale", "ja_JP"));

            assertThat(actuals.size(), is(2));
            JSONArray actual1 = actuals.get("my_id");
            JSONObject jsonObject1 = actual1.getJSONObject(0);
            assertThat(jsonObject1.getString("uid"), is("1234567890123456"));
            JSONArray actual2 = actuals.get("my_name");
            JSONObject jsonObject2 = actual2.getJSONObject(0);
            assertThat(jsonObject2.getString("name"), is("foo bar"));
        }
View Full Code Here

            assertThat(facebook.getEndpointURL(), is(pathOf("/")));

            assertThat(actuals.size(), is(1));

            BatchResponse batchResponse = actuals.get(0);
            JSONArray jsonArray = batchResponse.asJSONArray();
            assertThat(jsonArray.getJSONObject(0).getString("name"), is("Mark Zuckerberg"));
        }
View Full Code Here

TOP

Related Classes of facebook4j.internal.org.json.JSONArray

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.