本文整理汇总了Java中org.apache.shindig.protocol.RestfulCollection类的典型用法代码示例。如果您正苦于以下问题:Java RestfulCollection类的具体用法?Java RestfulCollection怎么用?Java RestfulCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RestfulCollection类属于org.apache.shindig.protocol包,在下文中一共展示了RestfulCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPeople_self
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_self() throws ExecutionException, InterruptedException {
String self = ID_1;
expect(token.getViewerId()).andReturn(self);
replay(token);
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.self, GROUP_ID);
expect(repository.findByUsername(self)).andReturn(getDbPerson());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, null, null, token);
assertThat(people, is(notNullValue()));
assertThat(people.get().getTotalResults(), is(equalTo(1)));
assertThat(people.get().getList().get(0).getId(), is(equalTo(self)));
}
示例2: getPeople_all
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_all() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.all, GROUP_ID);
replay(token);
expect(repository.findAllConnectedPeople(ID_2)).andReturn(getDbPersonList());
expect(repository.findAllConnectedPeople(ID_3)).andReturn(getDbPersonList());
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, null, null, token);
assertThat(people, is(notNullValue()));
assertThat(people.get().getList().get(0), is(instanceOf(FieldRestrictingPerson.class)));
assertThat(hasUniqueValues(people), is(true));
verify(repository);
}
示例3: getPeople_friends
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_friends() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.friends, GROUP_ID);
replay(token);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findFriends(ID_2)).andReturn(getDbPersonList());
expect(repository.findFriends(ID_3)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, null, null, token);
assertThat(people, is(notNullValue()));
assertThat(people.get().getList().get(0), is(instanceOf(FieldRestrictingPerson.class)));
assertThat(hasUniqueValues(people), is(true));
verify(repository);
}
示例4: getPeople_GroupFilterField
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_GroupFilterField() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.objectId, GROUP_ID);
replay(token);
CollectionOptions options = new CollectionOptions();
String field = Person.Field.ABOUT_ME.toString();
String value = "AAA";
options.setFilter(field);
options.setFilterOperation(FilterOperation.contains);
options.setFilterValue(value);
expect(repository.findByGroup(GROUP_ID, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例5: getPeople_AllFilterField
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_AllFilterField() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.all, GROUP_ID);
replay(token);
CollectionOptions options = new CollectionOptions();
String field = Person.Field.ABOUT_ME.toString();
String value = "AAA";
options.setFilter(field);
options.setFilterOperation(FilterOperation.contains);
options.setFilterValue(value);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findAllConnectedPeople(ID_2, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
expect(repository.findAllConnectedPeople(ID_3, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例6: getPeople_FriendsFilterField
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_FriendsFilterField() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.friends, GROUP_ID);
replay(token);
CollectionOptions options = new CollectionOptions();
String field = Person.Field.ABOUT_ME.toString();
String value = "AAA";
options.setFilter(field);
options.setFilterOperation(FilterOperation.contains);
options.setFilterValue(value);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findFriends(ID_2, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
expect(repository.findFriends(ID_3, field, FilterOperation.contains, value)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例7: getPeople_FriendsAllFilterField
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_FriendsAllFilterField() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.friends, GROUP_ID);
replay(token);
CollectionOptions options = new CollectionOptions();
String field = PersonService.ALL_FILTER;
String value = "AAA";
options.setFilter(field);
options.setFilterOperation(FilterOperation.contains);
options.setFilterValue(value);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findFriends(ID_2)).andReturn(getDbPersonList());
expect(repository.findFriends(ID_3)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例8: getPeople_friendHasAppFilterField
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_friendHasAppFilterField() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.friends, GROUP_ID);
String appId = "5";
expect(token.getAppId()).andReturn(appId).anyTimes();
replay(token);
CollectionOptions options = new CollectionOptions();
String field = PersonService.HAS_APP_FILTER;
options.setFilter(field);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findFriends(ID_2, appId)).andReturn(getDbPersonList());
expect(repository.findFriends(ID_3, appId)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例9: getPeople_allHasAppFilterField
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_allHasAppFilterField() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.all, GROUP_ID);
String appId = "5";
expect(token.getAppId()).andReturn(appId).anyTimes();
replay(token);
CollectionOptions options = new CollectionOptions();
String field = PersonService.HAS_APP_FILTER;
options.setFilter(field);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findAllConnectedPeople(ID_2, appId)).andReturn(getDbPersonList());
expect(repository.findAllConnectedPeople(ID_3, appId)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例10: getPeople_groupHasAppFilterField
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_groupHasAppFilterField() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.objectId, GROUP_ID);
String appId = "5";
expect(token.getAppId()).andReturn(appId).anyTimes();
replay(token);
CollectionOptions options = new CollectionOptions();
String field = PersonService.HAS_APP_FILTER;
options.setFilter(field);
expect(repository.findByGroup(GROUP_ID, appId)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例11: getPeople_friendIsFriendsWith
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_friendIsFriendsWith() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.friends, GROUP_ID);
String appId = "5";
expect(token.getAppId()).andReturn(appId);
replay(token);
CollectionOptions options = new CollectionOptions();
String field = PersonService.IS_WITH_FRIENDS_FILTER;
options.setFilter(field);
options.setFilterValue(ID_1);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findFriendsWithFriend(ID_2, ID_1)).andReturn(getDbPersonList());
expect(repository.findFriendsWithFriend(ID_3, ID_1)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例12: getPeople_allIsFriendsWith
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_allIsFriendsWith() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.all, GROUP_ID);
String appId = "5";
expect(token.getAppId()).andReturn(appId);
replay(token);
CollectionOptions options = new CollectionOptions();
String field = PersonService.IS_WITH_FRIENDS_FILTER;
options.setFilter(field);
options.setFilterValue(ID_1);
expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
expect(repository.findAllConnectedPeopleWithFriend(ID_2, ID_1)).andReturn(getDbPersonList());
expect(repository.findAllConnectedPeopleWithFriend(ID_3, ID_1)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例13: getPeople_groupIsFriendsWith
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
@Test
public void getPeople_groupIsFriendsWith() throws ExecutionException, InterruptedException {
Set<UserId> ids = getUserIdSet();
GroupId groupId = new GroupId(GroupId.Type.objectId, GROUP_ID);
String appId = "5";
expect(token.getAppId()).andReturn(appId).anyTimes();
replay(token);
CollectionOptions options = new CollectionOptions();
String field = PersonService.IS_WITH_FRIENDS_FILTER;
options.setFilter(field);
options.setFilterValue(ID_1);
expect(repository.findByGroupWithFriend(GROUP_ID, ID_1)).andReturn(getDbPersonList());
replay(repository);
Future<RestfulCollection<Person>> people = service.getPeople(ids, groupId, options, null, token);
assertThat(people, is(notNullValue()));
verify(repository);
}
示例14: getActivities
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
public Future<RestfulCollection<Activity>> getActivities(Set<UserId> userIds, GroupId groupId,
String appId, Set<String> fields, CollectionOptions options, SecurityToken token)
throws ProtocolException {
List<Activity> result = Lists.newArrayList();
try {
Set<String> idSet = getIdSet(userIds, groupId, token);
for (String id : idSet) {
if (db.getJSONObject(ACTIVITIES_TABLE).has(id)) {
JSONArray activities = db.getJSONObject(ACTIVITIES_TABLE).getJSONArray(id);
for (int i = 0; i < activities.length(); i++) {
JSONObject activity = activities.getJSONObject(i);
if (appId == null || !activity.has(Activity.Field.APP_ID.toString())) {
result.add(filterFields(activity, fields, Activity.class));
} else if (activity.get(Activity.Field.APP_ID.toString()).equals(appId)) {
result.add(filterFields(activity, fields, Activity.class));
}
}
}
}
return ImmediateFuture.newInstance(new RestfulCollection<Activity>(result));
} catch (JSONException je) {
throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(),
je);
}
}
示例15: getMessageCollections
import org.apache.shindig.protocol.RestfulCollection; //导入依赖的package包/类
public Future<RestfulCollection<MessageCollection>> getMessageCollections(UserId userId,
Set<String> fields, CollectionOptions options, SecurityToken token) throws ProtocolException {
try {
List<MessageCollection> result = Lists.newArrayList();
JSONObject messageCollections = db.getJSONObject(MESSAGE_TABLE).getJSONObject(
userId.getUserId(token));
for (String msgCollId : JSONObject.getNames(messageCollections)) {
JSONObject msgColl = messageCollections.getJSONObject(msgCollId);
msgColl.put("id", msgCollId);
JSONArray messages = msgColl.getJSONArray("messages");
int numMessages = (messages == null) ? 0 : messages.length();
msgColl.put("total", String.valueOf(numMessages));
msgColl.put("unread", String.valueOf(numMessages));
result.add(filterFields(msgColl, fields, MessageCollection.class));
}
return ImmediateFuture.newInstance(new RestfulCollection<MessageCollection>(result));
} catch (JSONException je) {
throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(),
je);
}
}