Package org.apache.shindig.social.opensocial.spi

Examples of org.apache.shindig.social.opensocial.spi.DataCollection


      assertEquals(ResponseError.BAD_REQUEST, sse.getError());
    }
  }

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

    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).size() == 2);
    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("count"));
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size"));
  }

  public void testGetExpectedAppDataForPlural() throws Exception {
    DataCollection responseItem = db.getPersonData(
        Sets.newHashSet(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());

    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).size() == 2);
    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());
    assertTrue(responseItem.getEntry().get(JOHN_DOE.getUserId()).size() == 1);
    assertTrue(responseItem.getEntry().get(JOHN_DOE.getUserId()).containsKey("count"));
  }
View Full Code Here

    // Delete the data
    db.deletePersonData(CANON_USER, SELF_GROUP, APP_ID,
        Sets.newHashSet("count"), new FakeGadgetToken());

    // Fetch the remaining and test
    DataCollection responseItem = db.getPersonData(
        Sets.newHashSet(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(),
        new FakeGadgetToken()).get();
    assertFalse(responseItem.getEntry().isEmpty());
    assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty());

    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).size() == 1);
    assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("count"));
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("size"));
  }
View Full Code Here

    // Delete the data
    db.updatePersonData(CANON_USER, SELF_GROUP, APP_ID,
        null, ImmutableMap.of("count", "10", "newvalue", "20"), new FakeGadgetToken());

    // Fetch the remaining and test
    DataCollection responseItem = db.getPersonData(
        Sets.newHashSet(CANON_USER), SELF_GROUP, APP_ID, Collections.<String>emptySet(),
        new FakeGadgetToken()).get();

    assertFalse(responseItem.getEntry().isEmpty());
    assertFalse(responseItem.getEntry().get(CANONICAL_USER_ID).isEmpty());

    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).size() == 3);
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("count"));
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).get("count").equals("10"));
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).containsKey("newvalue"));
    assertTrue(responseItem.getEntry().get(CANONICAL_USER_ID).get("newvalue").equals("20"));
  }
View Full Code Here

public class DataCollectionTest extends TestCase {

  public void testBasicMethods() throws Exception {
    Map<String, Map<String, String>> entry = Maps.newHashMap();
    DataCollection collection = new DataCollection(entry);
    assertEquals(entry, collection.getEntry());

    Map<String, Map<String, String>> newEntry = Maps.newHashMap();
    Map<String, String> value = Maps.newHashMap();
    value.put("knock knock", "who's there?");
    value.put("banana", "banana who?");
    value.put("banana!", "banana who?");
    value.put("orange!", "?");
    newEntry.put("orange you glad I didn't type banana", value);
    collection.setEntry(newEntry);
    assertEquals(newEntry, collection.getEntry());
  }
View Full Code Here

  }

  private void assertHandleGetForGroup(GroupId.Type group) throws Exception {
    setPath("/activities/john.doe/@" + group.toString() + "/appId");

    DataCollection data = new DataCollection(null);
    EasyMock.expect(appDataService.getPersonData(JOHN_DOE,
        new GroupId(group, null),
        "appId", Sets.<String>newHashSet(), token)).andReturn(ImmediateFuture.newInstance(data));

    replay();
View Full Code Here

  }

  public void testHandleGetPlural() throws Exception {
    setPath("/activities/john.doe,jane.doe/@self/appId");

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

  public void testHandleGetWithoutFields() throws Exception {
    Map<String, String> params = Maps.newHashMap();
    params.put("fields", "pandas");
    setPathAndParams("/appData/john.doe/@friends/appId", params);

    DataCollection data = new DataCollection(null);
    EasyMock.expect(appDataService.getPersonData(JOHN_DOE,
        new GroupId(GroupId.Type.friends, null),
        "appId", Sets.newHashSet("pandas"), token)).andReturn(ImmediateFuture.newInstance(data));

    replay();
View Full Code Here

   */
  @Override
  public void marshal(Object source, HierarchicalStreamWriter writer,
      MarshallingContext context) {

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

    if (false) {
      Map<String, String> m = internalMap.values().iterator().next();
      for (Entry<String, String> e : m.entrySet()) {
        writer.startNode("entry");
View Full Code Here

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

TOP

Related Classes of org.apache.shindig.social.opensocial.spi.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.