Package org.exoplatform.social.client.api.model

Examples of org.exoplatform.social.client.api.model.RestActivity


    final String GET_ACTIVITY_REQUEST_URL = BASE_URL+"activity/"+activityId+".json?" + queryParams.buildQuery();
    try{
      HttpResponse response = executeGet(GET_ACTIVITY_REQUEST_URL, POLICY.BASIC_AUTH);
      handleError(response);
      String responseContent = getContent(response);
      RestActivity restActivity = SocialJSONDecodingSupport.parser(RestActivity.class, responseContent);
      return restActivity;
    } catch (SocialHttpClientException e) {
      throw new ServiceException(ActivityServiceImplV1Alpha3.class, e.getMessage(), e);
    } catch (ParseException e) {
      throw new ServiceException(ActivityServiceImplV1Alpha3.class, e.getMessage(), e);
View Full Code Here


  }
 
  @Test
  public void testJSONParserWithClassType() throws Exception {
    String jsonActivity = "{\"numberOfComments\":1,\"identityId\":\"d5039b437f0001010011fd153a4fcbd8\",\"liked\":true,}";
    RestActivity model = SocialJSONDecodingSupport.parser(RestActivity.class, jsonActivity);
    assertEquals(model.getIdentityId(), "d5039b437f0001010011fd153a4fcbd8");
  }
View Full Code Here

  public void testJsonArrayParser() throws Exception {
    String jsonActivity = "[" +
                              "{\"numberOfComments\":1,\"identityId\":\"d5039b437f0001010011fd153a4fcbd8\",\"liked\":true,}," +
                              "{\"numberOfComments\":2,\"identityId\":\"d5039b437f0001010011fd153a4fcba8\",\"liked\":false,}" +
                           "]";
    RestActivity model1 = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonActivity).get(0);
    RestActivity model2 = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonActivity).get(1);
    assertEquals(model1.getIdentityId(), "d5039b437f0001010011fd153a4fcbd8");
    assertEquals(model2.getIdentityId(), "d5039b437f0001010011fd153a4fcba8");
   
   
    String jsonActivity1 = "{\"activities\":[" +
                                      "{" +
                                      "\"appId\":null,\"identityId\":\"f845f6ed7f000101003ed4d98a09beb3\"," +
                                      "\"totalNumberOfComments\":0,\"liked\":false,\"templateParams\":{}," +
                                      "\"postedTime\":1309839511830,\"type\":\"DEFAULT_ACTIVITY\"," +
                                      "\"posterIdentity\":null,\"activityStream\":null," +
                                      "\"id\":\"f884d11a7f000101000230e5c0e8a602\"," +
                                      "\"title\":\"hello\",\"priority\":null," +
                                      "\"createdAt\":\"Tue Jul 5 11:18:31 +0700 2011\"," +
                                      "\"likedByIdentities\":null,\"titleId\":null,\"comments\":null}" +
                           "]}";

    JSONObject jsonObject = (JSONObject) JSONValue.parse(jsonActivity1);
    JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
    RestActivity model3 = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString()).get(0);
    assertEquals(model3.getIdentityId(), "f845f6ed7f000101003ed4d98a09beb3");
  }
View Full Code Here

    final String id = "12345678";
    final String appId = "an_application_id";
    final double priority = 0.9;
    final String title = "title foo";
    final long postedTime = System.currentTimeMillis();
    RestActivity restActivity = new RestActivity();
    assertThat("restActivity must not be null", restActivity, notNullValue());
    restActivity.setId(id);
    restActivity.setAppId(appId);
    restActivity.setPostedTime(postedTime);
    restActivity.setPriority(priority);
    restActivity.setTitle(title);

    assertThat("restActivity.getAppId() must return: " + appId, restActivity.getAppId(), equalTo(appId));
    assertThat("restActivity.getId() must return: " + id, restActivity.getId(), equalTo(id));
    assertThat("restActivity.getPostedTime() must return: " + postedTime, restActivity.getPostedTime(), equalTo(postedTime));
    assertThat("restActivity.getPriority() must return: " + priority , restActivity.getPriority(), equalTo(priority));
    assertThat("restActivity.getTemplateParameter(\"foo\") must return null", restActivity.getTemplateParameter("foo"),
            nullValue());
    assertThat("restActivity.getTemplateParams() must return null", restActivity.getTemplateParams(), nullValue());
    assertThat("restActivity.getTitle() must return: " + title, restActivity.getTitle(), equalTo(title));
    assertThat("restActivity.getTitleId() must return null", restActivity.getTitleId(), nullValue());

    final Map<String, String> templateParams = new HashMap<String, String>();
    final String titleId = "title Id, title id";
    templateParams.put("foo", "bar");
    templateParams.put("foo2", "bar2");
    restActivity.setTemplateParams(templateParams);
    restActivity.setTitleId(titleId);

    assertThat("restActivity.getTemplateParams() must return: " + templateParams, restActivity.getTemplateParams(),
            equalTo(templateParams));
    assertThat("restActivity.getTemplateParameter(\"foo\") must return: bar", restActivity.getTemplateParameter("foo"),
            equalTo("bar"));
    assertThat("restActivity.getTemplateParameter(\"foo2\") must return: bar2",
            restActivity.getTemplateParameter("foo2"),
            equalTo("bar2"));
    assertThat("restActivity.getTitleId() must return: " + titleId, restActivity.getTitleId(), equalTo(titleId));
    restActivity.addTemplateParameter("foo3", "bar3");
    assertThat("restActivity.getTemplateParameter(\"foo3\") must return: bar3", restActivity.getTemplateParameter("foo3"),
            equalTo("bar3"));
  }
View Full Code Here

                              + "\"title\": \"Activity Stream of Root Root\","
                              + "\"permaLink\": \"http://localhost:8080/profile/root\""
                              +"}" //optional
                              +"}\"";

    RestActivity model3 = SocialJSONDecodingSupport.parser(RestActivity.class, jsonActivity1);
    assertEquals(model3.getIdentityId(), "123456789abcdefghi");

    //
    JSONObject jsonObject = (JSONObject) JSONValue.parse(jsonActivity1);
    JSONArray jsonArray =  (JSONArray)jsonObject.get("likedByIdentities");
    //
    String actual = model3.getFieldAsString("likedByIdentities");

    assertEquals(actual, jsonArray.toJSONString());

    List<RestIdentity> identities = SocialJSONDecodingSupport.JSONArrayObjectParser(RestIdentity.class, actual);
    assertEquals(identities.size(), 1);
View Full Code Here

                                      "\"likedByIdentities\":null,\"titleId\":null,\"comments\":null}" +
                           "]}";

    JSONObject jsonObject = (JSONObject) JSONValue.parse(jsonActivity1);
    JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
    RestActivity model3 = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString()).get(0);
    assertEquals(model3.getIdentityId(), "f845f6ed7f000101003ed4d98a09beb3");
  }
View Full Code Here

      activityService.get("notfound");
      fail("Expecting ServiceException from ActivityService#get(String)");
    } catch (ServiceException se) {

    }
    RestActivity activity = new RestActivity();
    activity.setTitle("Hello There");
    try {
      activityService.create(activity);
      fail("Expecting ServiceException from ActivityService#create(RestActivity)");
    } catch (ServiceException se) {

    }

    try {
      activityService.update(activity);
      fail("Expecting UnsupportedMethodException from ActivityService#update(RestActivity)");
    } catch (UnsupportedMethodException e) {

    }

    //create a activity to demo's stream
    startSessionAs("root", "gtn");
   
    RestActivity demoActivity = createActivities(1).get(0);
    startSessionAsAnonymous();

    RestComment comment = new RestComment();
    comment.setText("comment");
View Full Code Here

    if (!canRunTest()) {
      return;
    }
    startSessionAs("root", "gtn");
    RestIdentity restIdentity = identityService.getIdentity("organization", "root");
    RestActivity activity = new RestActivity();
    activity.setTitle("Hello World");
    RestActivity resultActivity = activityService.create(activity);

    assertThat("resultActivity's title should be: \"Hello World\"", "Hello World", equalTo(resultActivity.getTitle()));

    assertThat("resultActivity's identityId should be:  restIdentity.getId()", restIdentity.getId(), equalTo(resultActivity.getIdentityId()));
  }
View Full Code Here

  public void shouldGet() throws SocialClientLibException {
    if (!canRunTest()) {
      return;
    }
    startSessionAs("root", "gtn");
    RestActivity restActivity = createActivities(1).get(0);
    String activityId = restActivity.getId();
    RestActivity resultActivity = activityService.get(activityId);

    assertThat("test 0", equalTo(resultActivity.getTitle()));
    assertNotNull(resultActivity.getLastUpdated());
    assertTrue(resultActivity.getLastUpdated().longValue() > 0);

    RestActivityStream activityStream = resultActivity.getActivityStream();
    assertThat(activityStream.getFullName(), equalTo("Root Root"));
    assertThat(activityStream.getType(), equalTo("organization"));
   
  }
View Full Code Here

    if (!canRunTest()) {
      return;
    }
    startSessionAs("root", "gtn");
    String activityId = createActivities(1).get(0).getId();
    RestActivity resultActivity = activityService.get(activityId);
    activityService.delete(resultActivity);

    tearDownActivityList.remove(0);

    try{
View Full Code Here

TOP

Related Classes of org.exoplatform.social.client.api.model.RestActivity

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.