Package org.apache.shindig.social.opensocial.model

Examples of org.apache.shindig.social.opensocial.model.Person


      JSONArray people = db.getJSONArray(PEOPLE_TABLE);

      for (int i = 0; i < people.length(); i++) {
        JSONObject person = people.getJSONObject(i);
        if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) {
          Person personObj = filterFields(person, fields, Person.class);
          Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID
              .toString()), fields);
          personObj.setAppData(appData);

          return ImmediateFuture.newInstance(personObj);
        }
      }
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person '" + id.getUserId(token) + "' not found");
View Full Code Here


    db = injector.getInstance(JsonDbOpensocialService.class);
  }

  @Test
  public void testGetPersonDefaultFields() throws Exception {
    Person person = db
        .getPerson(CANON_USER, Person.Field.DEFAULT_FIELDS, token).get();

    assertNotNull("Canonical user not found", person);
    assertNotNull("Canonical user has no id", person.getId());
    assertNotNull("Canonical user has no name", person.getName());
    assertNotNull("Canonical user has no thumbnail",
        person.getThumbnailUrl());
  }
View Full Code Here

        person.getThumbnailUrl());
  }

  @Test
  public void testGetPersonAllFields() throws Exception {
    Person person = db
        .getPerson(CANON_USER, Person.Field.ALL_FIELDS, token).get();
    assertNotNull("Canonical user not found", person);
  }
View Full Code Here

    assertNotNull("Canonical user not found", person);
  }

  @Test
  public void testGetPersonAllAppData() throws Exception {
    Person person = db
        .getPerson(CANON_USER, ImmutableSet.of("id", "appData"), token).get();

    assertNotNull("Canonical user not found", person);
    assertEquals("Canonical user has wrong id", "canonical", person.getId());
    assertEquals("Canonical user has wrong app data",
        ImmutableMap.of("count", "2", "size", "100"), person.getAppData());
  }
View Full Code Here

        ImmutableMap.of("count", "2", "size", "100"), person.getAppData());
  }

  @Test
  public void testGetPersonOneAppDataField() throws Exception {
    Person person = db
        .getPerson(CANON_USER, ImmutableSet.of("id", "appData.size"), token).get();

    assertNotNull("Canonical user not found", person);
    assertEquals("Canonical user has wrong id", "canonical", person.getId());
    assertEquals("Canonical user has wrong app data",
        ImmutableMap.of("size", "100"), person.getAppData());
  }
View Full Code Here

        ImmutableMap.of("size", "100"), person.getAppData());
  }

  @Test
  public void testGetPersonMultipleAppDataFields() throws Exception {
    Person person = db
        .getPerson(CANON_USER,
            ImmutableSet.of("id", "appData.size", "appData.count", "appData.bogus"),
            token).get();

    assertNotNull("Canonical user not found", person);
    assertEquals("Canonical user has wrong id", "canonical", person.getId());
    assertEquals("Canonical user has wrong app data",
        ImmutableMap.of("count", "2", "size", "100"), person.getAppData());
  }
View Full Code Here

    SecurityToken updateToken = new FakeGadgetToken("appId", "appUrl", "domain", "updatePerson", "trustedJson", "updatePerson", "20");

    // Get user
    UserId userId = new UserId(UserId.Type.userId, "updatePerson");
    Person person = db
        .getPerson(userId, Person.Field.ALL_FIELDS, token).get();
    assertNotNull("User 'updatePerson' not found", person);

    // update a field in user object
    person.setThumbnailUrl("http://newthumbnail.url");
    // Save user to db
    db.updatePerson(userId, person, updateToken);
    // Get user again from db and check if the fields were properly updated
    person = db.getPerson(userId, Person.Field.ALL_FIELDS, token).get();
    assertNotNull("User 'updatePerson' not found", person);

    assertEquals("http://newthumbnail.url", person.getThumbnailUrl());
  }
View Full Code Here

    SecurityToken updateToken = new FakeGadgetToken("appId", "appUrl", "domain", "viewer", "trustedJson", "viewer", "20");

    // Get user
    UserId userId = new UserId(UserId.Type.userId, "updatePerson");
    Person person = db
        .getPerson(userId, Person.Field.ALL_FIELDS, token).get();

    // update a field in user object
    person.setThumbnailUrl("http://newthumbnail.url");
    // Save user to db, should throw an exception
    try {
      db.updatePerson(userId, person, updateToken);
      fail();
    } catch (ProtocolException sse) {
View Full Code Here

  @Test
  public void testHandleGetFriendById() throws Exception {
    String path = "/people/john.doe/@friends/jane.doe";
    RestHandler operation = registry.getRestHandler(path, "GET");

    Person person = new PersonImpl();
    List<Person> people = Lists.newArrayList(person);
    RestfulCollection<Person> data = new RestfulCollection<Person>(people);
    // TODO: We aren't passing john.doe to the service yet.
    expect(personService.getPeople(
        eq(ImmutableSet.of(new UserId(UserId.Type.userId, "jane.doe"))),
View Full Code Here

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

    Person data = new PersonImpl();
    expect(personService.getPerson(eq(JOHN_DOE.iterator().next()),
        eq(DEFAULT_FIELDS), eq(token))).andReturn(ImmediateFuture.newInstance(data));

    replay();
    assertEquals(data, operation.execute(Maps.<String, String[]>newHashMap(),
View Full Code Here

TOP

Related Classes of org.apache.shindig.social.opensocial.model.Person

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.