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

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


    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)))
        .andReturn(ImmediateFuture.newInstance(data));
View Full Code Here


    bootstrap.tearDown();
  }

  @Test
  public void getCanonicalPerson() throws Exception {
     Future<Person> person = this.personServiceDb.getPerson(new UserId(Type.userId, "canonical"), Person.Field.ALL_FIELDS, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
     SpiTestUtil.assertPersonEquals(person.get(), canonical);
  }
View Full Code Here

  @Test
  public void testViewerCanUpdatePerson() throws Exception {
    Person p = SpiTestUtil.buildCanonicalPerson();
    p.setThumbnailUrl("http://newthumbnail.url");
    this.personServiceDb.updatePerson(new UserId(Type.userId, "canonical"),
        p, SpiTestUtil.CANONICAL_PERSON_SECURITY_TOKEN);

    Future<Person> person = this.personServiceDb.getPerson(new UserId(Type.userId, "canonical"), ImmutableSet.of("id","displayName","thumbnailUrl"), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    assertEquals("http://newthumbnail.url", person.get().getThumbnailUrl());
  }
View Full Code Here

  public void testViewerNotAllowedUpdatePerson() throws Exception {
    Person p = SpiTestUtil.buildCanonicalPerson();
    p.setThumbnailUrl("http://newthumbnail.url");

    try {
      this.personServiceDb.updatePerson(new UserId(Type.userId, "canonical"),
          p, SpiTestUtil.JOHN_DOE_SECURITY_TOKEN);
      org.junit.Assert.fail();
    } catch (ProtocolException sse) {
      assertEquals(HttpServletResponse.SC_FORBIDDEN, sse.getCode());
    }
View Full Code Here

    bootstrap.tearDown();
  }

  @Test
  public void getJohnDoeActivityWithAppId1() throws Exception {
    Future<Activity> result = this.activityServiceDb.getActivity(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), null, ACTIVITY_ALL_FIELDS, "1", SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    Activity activity = result.get();
    SpiTestUtil.assertActivityEquals(activity, testActivity);
  }
View Full Code Here

  public void createNewActivityForJohnDoe() throws Exception {
    // Create new activity
    final String title = "hi mom!";
    final String body = "and dad.";
    Activity activity = SpiTestUtil.buildTestActivity("2", "john.doe", title, body);
    this.activityServiceDb.createActivity(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), "2", ACTIVITY_ALL_FIELDS, activity, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);

    // Check activity was created as expected
    Future<RestfulCollection<Activity>> result = this.activityServiceDb.getActivities(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.self, "@self"), null, ACTIVITY_ALL_FIELDS, new CollectionOptions(), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    RestfulCollection<Activity> activityCollection = result.get();
    assertEquals(2, activityCollection.getTotalResults());
View Full Code Here

  @Test
  public void updateJohnDoeApplicationDataSettingCountTo5() throws Exception {
    // Do update
    Map<String, String> values = new MapMaker().makeMap();
    values.put("count", "5");
    this.appDataServiceDb.updatePersonData(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, SpiTestUtil.asSet("count"), values, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);

    // Verify that update succeeded
    Future<DataCollection> results = this.appDataServiceDb.getPersonData(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, null, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    DataCollection data = results.get();
    assertEquals(1, data.getEntry().size());
View Full Code Here

  }

  @Test
  public void deleteJohnDoeApplicationDataWithCountField() throws Exception {
    // Do delete
    this.appDataServiceDb.deletePersonData(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, SpiTestUtil.asSet("count"), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    // Verify that delete succeeded
    Future<DataCollection> results = this.appDataServiceDb.getPersonData(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, SpiTestUtil.asSet("count"), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    DataCollection data = results.get();
    assertEquals(1, data.getEntry().size());
    assertEquals(null, data.getEntry().get("john.doe").get("count"));
View Full Code Here

  }

  @Test
  public void deleteJohnDoeApplicationDataWithInvalidField() throws Exception {
    // Do delete with invalid field
    this.appDataServiceDb.deletePersonData(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, SpiTestUtil.asSet("peabody"), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    // Verify that delete did not occur
    Future<DataCollection> results = this.appDataServiceDb.getPersonData(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, SpiTestUtil.asSet("count"), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    DataCollection data = results.get();
    assertEquals(1, data.getEntry().size());
    assertEquals("0", data.getEntry().get("john.doe").get("count"));
View Full Code Here

          return personService.getPeople(userIds, groupId, options, fields, request.getToken());
        }
      } else if (optionalPersonId.size() == 1) {
        // TODO: Add some crazy concept to handle the userId?
        Set<UserId> optionalUserIds = ImmutableSet.of(
            new UserId(UserId.Type.userId, optionalPersonId.iterator().next()));

        Future<RestfulCollection<Person>> people = personService.getPeople(
            optionalUserIds, new GroupId(GroupId.Type.self, null),
            options, fields, request.getToken());
        return FutureUtil.getFirstFromCollection(people);
      } else {
        ImmutableSet.Builder<UserId> personIds = ImmutableSet.builder();
        for (String pid : optionalPersonId) {
          personIds.add(new UserId(UserId.Type.userId, pid));
        }
        // Every other case is a collection response of optional person ids
        return personService.getPeople(personIds.build(), new GroupId(GroupId.Type.self, null),
            options, fields, request.getToken());
      }
View Full Code Here

TOP

Related Classes of org.apache.shindig.social.opensocial.spi.UserId

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.