Package org.apache.shindig.protocol

Examples of org.apache.shindig.protocol.DataCollection


            if (!dataCollectionMap.containsKey(personId)) {
                dataCollectionMap.put(personId, new HashMap<String, Object>());
            }
        }

        return new DataCollection(dataCollectionMap);
    }
View Full Code Here


  private void assertHandleGetForGroup(GroupId.Type group) throws Exception {
    String path = "/appdata/john.doe/@" + group.toString() + "/appId";
    RestHandler operation = registry.getRestHandler(path, "GET");

    DataCollection data = new DataCollection(null);
    org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE),
        eq(new GroupId(group, null)),
        eq("appId"), eq(ImmutableSet.<String>of()), eq(token)))
        .andReturn(Futures.immediateFuture(data));
View Full Code Here

  @Test
  public void testHandleGetPlural() throws Exception {
    String path = "/appdata/john.doe,jane.doe/@self/appId";
    RestHandler operation = registry.getRestHandler(path, "GET");

    DataCollection data = new DataCollection(null);
    Set<UserId> userIdSet = Sets.newLinkedHashSet(JOHN_DOE);
    userIdSet.add(new UserId(UserId.Type.userId, "jane.doe"));
    org.easymock.EasyMock.expect(appDataService.getPersonData(eq(userIdSet),
        eq(new GroupId(GroupId.Type.self, null)),
        eq("appId"), eq(ImmutableSet.<String>of()), eq(token)))
View Full Code Here

    RestHandler operation = registry.getRestHandler(path, "GET");

    Map<String, String[]> params = Maps.newHashMap();
    params.put("fields", new String[]{"pandas"});

    DataCollection data = new DataCollection(null);
    org.easymock.EasyMock.expect(appDataService.getPersonData(eq(JOHN_DOE),
        eq(new GroupId(GroupId.Type.friends, null)),
        eq("appId"), eq(ImmutableSet.of("pandas")), eq(token)))
        .andReturn(Futures.immediateFuture(data));
View Full Code Here

      }
      startIndex = 0;
      totalResults = entry.size();
      itemsPerPage = entry.size();
    } else if ( obj instanceof DataCollection ) {
      DataCollection dc = (DataCollection) obj;
      entry = Lists.newArrayList();
      for ( Entry<String, Map<String,Object>> o : dc.getEntry().entrySet()) {
        entry.add(new AtomEntry(o));
      }
      startIndex = 0;
      totalResults = entry.size();
      itemsPerPage = entry.size();
View Full Code Here

          String key = keys.next();
          data.put(key, personData.getString(key));
        }
        idToData.put(id, data);
      }
      return Futures.immediateFuture(new DataCollection(idToData));
    } catch (JSONException je) {
      throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(),
          je);
    }
  }
View Full Code Here

   *      com.thoughtworks.xstream.converters.MarshallingContext)
   */
  @Override
  public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {

    DataCollection collection = (DataCollection) source;
    Map<String, Map<String, Object>> internalMap = collection.getEntry();

    for (Entry<String, Map<String, Object>> eo : internalMap.entrySet()) {
      writer.startNode("entry");
      writer.startNode("key");
      writer.setValue(eo.getKey());
View Full Code Here

    } else {
      for (Entry<String, Object> e : m.entrySet()) {
        fm.put(e.getKey(), (Map<String, Object>) e.getValue());
      }
    }
    return new DataCollection(fm);
  }
View Full Code Here

    }
  }

  @Test
  public void testGetExpectedAppData() throws Exception {
    DataCollection responseItem = db.getPersonData(
        ImmutableSet.of(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(),
        new FakeGadgetToken()).get();
    assertFalse(responseItem.getEntry().isEmpty());
    assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty());

    assertSame(2, responseItem.getEntry().get(CANONICAL_USER_ID).size());
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("count"));
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size"));
  }
View Full Code Here

    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size"));
  }

  @Test
  public void testGetExpectedAppDataForPlural() throws Exception {
    DataCollection responseItem = db.getPersonData(
        ImmutableSet.of(CANON_USER, JOHN_DOE), SELF_GROUP, APP_ID, Collections.<String>emptySet(),
        new FakeGadgetToken()).get();
    assertFalse(responseItem.getEntry().isEmpty());
    assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty());

    assertSame(2, responseItem.getEntry().get(CANONICAL_USER_ID).size());
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("count"));
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size"));

    assertFalse(responseItem.getEntry().get(JOHN_DOE.getUserId()).isEmpty());
    assertSame(1, responseItem.getEntry().get(JOHN_DOE.getUserId()).size());
    assertTrue(responseItem.getEntry().get(JOHN_DOE.getUserId()).containsKey("count"));
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.protocol.DataCollection

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.