當前位置: 首頁>>代碼示例>>Java>>正文


Java RestfulCollection類代碼示例

本文整理匯總了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)));
}
 
開發者ID:apache,項目名稱:rave,代碼行數:18,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:19,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:20,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:21,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:25,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:24,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:24,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:24,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:24,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:20,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:25,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:25,代碼來源:PersonServiceTest.java

示例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);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:21,代碼來源:PersonServiceTest.java

示例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);
  }
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:26,代碼來源:JsonDbOpensocialService.java

示例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);
  }
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:23,代碼來源:JsonDbOpensocialService.java


注:本文中的org.apache.shindig.protocol.RestfulCollection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。