Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete v1.0 compatibility from permissions api #79

Merged
merged 1 commit into from
Oct 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
import facebook4j.internal.org.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import static facebook4j.internal.util.z_F4JInternalParseUtil.*;

/**
* @author Ryuji Yamashita - roundrop at gmail.com
*/
Expand Down Expand Up @@ -64,18 +61,9 @@ static List<Permission> createPermissionArray(HttpResponse res, Configuration co
JSONArray list = json.getJSONArray("data");
for (int i = 0; i < list.length(); i++) {
JSONObject permissionJSONObject = list.getJSONObject(i);
if (permissionJSONObject.has("permission") && permissionJSONObject.has("status")) {
String permissionName = permissionJSONObject.getString("permission");
boolean isGranted = "granted".equalsIgnoreCase(permissionJSONObject.getString("status"));
permissions.add(new PermissionJSONImpl(permissionName, isGranted));
} else {
Iterator<String> permissionNames = permissionJSONObject.keys();
while (permissionNames.hasNext()) {
String permissionName = permissionNames.next();
boolean isGranted = getFlag(permissionName, permissionJSONObject);
permissions.add(new PermissionJSONImpl(permissionName, isGranted));
}
}
String permissionName = permissionJSONObject.getString("permission");
boolean isGranted = "granted".equalsIgnoreCase(permissionJSONObject.getString("status"));
permissions.add(new PermissionJSONImpl(permissionName, isGranted));
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(permissions, list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,6 @@ public void id() throws Exception {
assertThat(actuals.size(), is(80));
}

@Test
public void me_v2() throws Exception {
facebook.setMockJSON("mock_json/permission/all_v2.2.json");
List<Permission> actuals = facebook.getPermissions();
assertThat(facebook.getHttpMethod(), is(RequestMethod.GET));
assertThat(facebook.getEndpointURL(), is(pathOf("/me/permissions")));

assertThat(actuals.size(), is(80));
}

@Test
public void id_v2() throws Exception {
facebook.setMockJSON("mock_json/permission/all_v2.2.json");
List<Permission> actuals = facebook.getPermissions("1234567890123456");
assertThat(facebook.getHttpMethod(), is(RequestMethod.GET));
assertThat(facebook.getEndpointURL(), is(pathOf("/1234567890123456/permissions")));

assertThat(actuals.size(), is(80));
}
}

public static class revokePermission extends MockFacebookTestBase {
Expand Down
164 changes: 82 additions & 82 deletions facebook4j-core/src/test/resources/mock_json/permission/all.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
{
"data": [{
"ads_management": 1,
"basic_info": 1,
"create_event": 1,
"create_note": 1,
"email": 1,
"export_stream": 1,
"friends_about_me": 1,
"friends_actions.music": 1,
"friends_actions.news": 1,
"friends_actions.video": 1,
"friends_activities": 1,
"friends_birthday": 1,
"friends_education_history": 1,
"friends_events": 1,
"friends_games_activity": 1,
"friends_groups": 1,
"friends_hometown": 1,
"friends_interests": 1,
"friends_likes": 1,
"friends_location": 1,
"friends_notes": 1,
"friends_online_presence": 1,
"friends_photo_video_tags": 1,
"friends_photos": 1,
"friends_questions": 1,
"friends_relationship_details": 1,
"friends_relationships": 1,
"friends_religion_politics": 1,
"friends_status": 1,
"friends_subscriptions": 1,
"friends_videos": 1,
"friends_website": 1,
"friends_work_history": 1,
"installed": 1,
"manage_friendlists": 1,
"manage_notifications": 1,
"manage_pages": 1,
"photo_upload": 1,
"publish_actions": 1,
"publish_checkins": 1,
"publish_stream": 1,
"read_friendlists": 1,
"read_insights": 1,
"read_mailbox": 1,
"read_page_mailboxes": 1,
"read_requests": 1,
"read_stream": 1,
"rsvp_event": 1,
"share_item": 1,
"sms": 1,
"status_update": 1,
"user_about_me": 1,
"user_actions.music": 1,
"user_actions.news": 1,
"user_actions.video": 1,
"user_activities": 1,
"user_birthday": 1,
"user_education_history": 1,
"user_events": 1,
"user_games_activity": 1,
"user_groups": 1,
"user_hometown": 1,
"user_interests": 1,
"user_likes": 1,
"user_location": 1,
"user_notes": 1,
"user_online_presence": 1,
"user_photo_video_tags": 1,
"user_photos": 1,
"user_questions": 1,
"user_relationship_details": 1,
"user_relationships": 1,
"user_religion_politics": 1,
"user_status": 1,
"user_subscriptions": 1,
"user_videos": 1,
"user_website": 1,
"user_work_history": 1,
"video_upload": 1,
"xmpp_login": 1
}],
"data": [
{"permission":"ads_management","status":"granted"},
{"permission":"basic_info","status":"granted"},
{"permission":"create_event","status":"granted"},
{"permission":"create_note","status":"granted"},
{"permission":"email","status":"granted"},
{"permission":"export_stream","status":"granted"},
{"permission":"friends_about_me","status":"granted"},
{"permission":"friends_actions.music","status":"granted"},
{"permission":"friends_actions.news","status":"granted"},
{"permission":"friends_actions.video","status":"granted"},
{"permission":"friends_activities","status":"granted"},
{"permission":"friends_birthday","status":"granted"},
{"permission":"friends_education_history","status":"granted"},
{"permission":"friends_events","status":"granted"},
{"permission":"friends_games_activity","status":"granted"},
{"permission":"friends_groups","status":"granted"},
{"permission":"friends_hometown","status":"granted"},
{"permission":"friends_interests","status":"granted"},
{"permission":"friends_likes","status":"granted"},
{"permission":"friends_location","status":"granted"},
{"permission":"friends_notes","status":"granted"},
{"permission":"friends_online_presence","status":"granted"},
{"permission":"friends_photo_video_tags","status":"granted"},
{"permission":"friends_photos","status":"granted"},
{"permission":"friends_questions","status":"granted"},
{"permission":"friends_relationship_details","status":"granted"},
{"permission":"friends_relationships","status":"granted"},
{"permission":"friends_religion_politics","status":"granted"},
{"permission":"friends_status","status":"granted"},
{"permission":"friends_subscriptions","status":"granted"},
{"permission":"friends_videos","status":"granted"},
{"permission":"friends_website","status":"granted"},
{"permission":"friends_work_history","status":"granted"},
{"permission":"installed","status":"granted"},
{"permission":"manage_friendlists","status":"granted"},
{"permission":"manage_notifications","status":"granted"},
{"permission":"manage_pages","status":"granted"},
{"permission":"photo_upload","status":"granted"},
{"permission":"publish_actions","status":"granted"},
{"permission":"publish_checkins","status":"granted"},
{"permission":"publish_stream","status":"granted"},
{"permission":"read_friendlists","status":"granted"},
{"permission":"read_insights","status":"granted"},
{"permission":"read_mailbox","status":"granted"},
{"permission":"read_page_mailboxes","status":"granted"},
{"permission":"read_requests","status":"granted"},
{"permission":"read_stream","status":"granted"},
{"permission":"rsvp_event","status":"granted"},
{"permission":"share_item","status":"granted"},
{"permission":"sms","status":"granted"},
{"permission":"status_update","status":"granted"},
{"permission":"user_about_me","status":"granted"},
{"permission":"user_actions.music","status":"granted"},
{"permission":"user_actions.news","status":"granted"},
{"permission":"user_actions.video","status":"granted"},
{"permission":"user_activities","status":"granted"},
{"permission":"user_birthday","status":"granted"},
{"permission":"user_education_history","status":"granted"},
{"permission":"user_events","status":"granted"},
{"permission":"user_games_activity","status":"granted"},
{"permission":"user_groups","status":"granted"},
{"permission":"user_hometown","status":"granted"},
{"permission":"user_interests","status":"granted"},
{"permission":"user_likes","status":"granted"},
{"permission":"user_location","status":"granted"},
{"permission":"user_notes","status":"granted"},
{"permission":"user_online_presence","status":"granted"},
{"permission":"user_photo_video_tags","status":"granted"},
{"permission":"user_photos","status":"granted"},
{"permission":"user_questions","status":"granted"},
{"permission":"user_relationship_details","status":"granted"},
{"permission":"user_relationships","status":"granted"},
{"permission":"user_religion_politics","status":"granted"},
{"permission":"user_status","status":"granted"},
{"permission":"user_subscriptions","status":"granted"},
{"permission":"user_videos","status":"granted"},
{"permission":"user_website","status":"granted"},
{"permission":"user_work_history","status":"granted"},
{"permission":"video_upload","status":"granted"},
{"permission":"xmpp_login","status":"granted"}
],
"paging": {"next": "https://graph.facebook.com/1234567890123456/permissions?access_token=access_token&limit=5000&offset=5000"}
}

This file was deleted.