@Test(expected = ProtocolException.class) public void testGetActivitiesThrowsException() throws Exception { LinkedHashSet<UserId> userIdSet = new LinkedHashSet<UserId>(); userIdSet.add(testId); userIdSet.add(testId2); CollectionOptions collOptions = new CollectionOptions(); context.checking(new Expectations() { { allowing(principalDao).execute(with(any(String.class))); will(returnValue(principalMock)); allowing(principalMock).getAccountId(); will(returnValue("foo")); oneOf(serviceActionControllerMock).execute(with(any(ServiceActionContext.class)), with(any(ServiceAction.class))); will(throwException(new GeneralException())); } }); sut.getActivities(userIdSet, testGroupId, TEST_APP_ID, ACTIVITY_ALL_FIELDS, collOptions, FAKETOKEN).get(); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") public Future<RestfulCollection<Activity>> getActivities(final Set<UserId> userIds, final GroupId groupId, final String appId, final Set<String> fields, final CollectionOptions options, final SecurityToken token) { log.trace("Entering getActivities"); List<Activity> osActivities = new ArrayList<Activity>(); try { Set<String> userIdList = new HashSet<String>(); for (UserId currentUserId : userIds) { if (!currentUserId.getUserId(token).equals("null")) { userIdList.add(currentUserId.getUserId(token)); } } log.debug("Sending getActivities userIdList to action: " + userIdList.toString()); GetUserActivitiesRequest currentRequest = new GetUserActivitiesRequest(new ArrayList<Long>(), userIdList); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, openSocialPrincipalDao.execute(token.getViewerId())); LinkedList<ActivityDTO> activities = (LinkedList<ActivityDTO>) serviceActionController.execute( currentContext, getUserActivitiesAction); log.debug("Retrieved " + activities.size() + " activities from action"); for (ActivityDTO currentActivity : activities) { osActivities.add(convertActivityFromEurekaActivityDTOToOS(currentActivity)); } } catch (Exception ex) { log.error("Error occurred retrieving activities ", ex); throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); } return ImmediateFuture.newInstance(new RestfulCollection<Activity>(osActivities)); }
ActivityServiceImpl implements ActivityService { @SuppressWarnings("unchecked") public Future<RestfulCollection<Activity>> getActivities(final Set<UserId> userIds, final GroupId groupId, final String appId, final Set<String> fields, final CollectionOptions options, final SecurityToken token) { log.trace("Entering getActivities"); List<Activity> osActivities = new ArrayList<Activity>(); try { Set<String> userIdList = new HashSet<String>(); for (UserId currentUserId : userIds) { if (!currentUserId.getUserId(token).equals("null")) { userIdList.add(currentUserId.getUserId(token)); } } log.debug("Sending getActivities userIdList to action: " + userIdList.toString()); GetUserActivitiesRequest currentRequest = new GetUserActivitiesRequest(new ArrayList<Long>(), userIdList); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, openSocialPrincipalDao.execute(token.getViewerId())); LinkedList<ActivityDTO> activities = (LinkedList<ActivityDTO>) serviceActionController.execute( currentContext, getUserActivitiesAction); log.debug("Retrieved " + activities.size() + " activities from action"); for (ActivityDTO currentActivity : activities) { osActivities.add(convertActivityFromEurekaActivityDTOToOS(currentActivity)); } } catch (Exception ex) { log.error("Error occurred retrieving activities ", ex); throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); } return ImmediateFuture.newInstance(new RestfulCollection<Activity>(osActivities)); } }
ActivityServiceImpl implements ActivityService { @SuppressWarnings("unchecked") public Future<RestfulCollection<Activity>> getActivities(final Set<UserId> userIds, final GroupId groupId, final String appId, final Set<String> fields, final CollectionOptions options, final SecurityToken token) { log.trace("Entering getActivities"); List<Activity> osActivities = new ArrayList<Activity>(); try { Set<String> userIdList = new HashSet<String>(); for (UserId currentUserId : userIds) { if (!currentUserId.getUserId(token).equals("null")) { userIdList.add(currentUserId.getUserId(token)); } } log.debug("Sending getActivities userIdList to action: " + userIdList.toString()); GetUserActivitiesRequest currentRequest = new GetUserActivitiesRequest(new ArrayList<Long>(), userIdList); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, openSocialPrincipalDao.execute(token.getViewerId())); LinkedList<ActivityDTO> activities = (LinkedList<ActivityDTO>) serviceActionController.execute( currentContext, getUserActivitiesAction); log.debug("Retrieved " + activities.size() + " activities from action"); for (ActivityDTO currentActivity : activities) { osActivities.add(convertActivityFromEurekaActivityDTOToOS(currentActivity)); } } catch (Exception ex) { log.error("Error occurred retrieving activities ", ex); throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); } return ImmediateFuture.newInstance(new RestfulCollection<Activity>(osActivities)); } @Inject  ActivityServiceImpl(@Named("getUserActivities") final ServiceAction inGetUserActivitiesAction,
            @Named("deleteUserActivities") final TaskHandlerAction inDeleteActivitiesAction,
            final ActionController inServiceActionController,
            @Named("openSocialPrincipalDao") final DomainMapper<String, Principal> inOpenSocialPrincipalDao,
            @Named("postPersonActivityServiceActionTaskHandler") final TaskHandlerServiceAction inPostActivityAction,
            @Named("jpaGadgetDefinitionMapper") final GadgetDefinitionMapper inGadgetDefinitionMapper,
            final GadgetMetaDataFetcher inGadgetMetaDataFetcher); }
ActivityServiceImpl implements ActivityService { @SuppressWarnings("unchecked") public Future<RestfulCollection<Activity>> getActivities(final Set<UserId> userIds, final GroupId groupId, final String appId, final Set<String> fields, final CollectionOptions options, final SecurityToken token) { log.trace("Entering getActivities"); List<Activity> osActivities = new ArrayList<Activity>(); try { Set<String> userIdList = new HashSet<String>(); for (UserId currentUserId : userIds) { if (!currentUserId.getUserId(token).equals("null")) { userIdList.add(currentUserId.getUserId(token)); } } log.debug("Sending getActivities userIdList to action: " + userIdList.toString()); GetUserActivitiesRequest currentRequest = new GetUserActivitiesRequest(new ArrayList<Long>(), userIdList); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, openSocialPrincipalDao.execute(token.getViewerId())); LinkedList<ActivityDTO> activities = (LinkedList<ActivityDTO>) serviceActionController.execute( currentContext, getUserActivitiesAction); log.debug("Retrieved " + activities.size() + " activities from action"); for (ActivityDTO currentActivity : activities) { osActivities.add(convertActivityFromEurekaActivityDTOToOS(currentActivity)); } } catch (Exception ex) { log.error("Error occurred retrieving activities ", ex); throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); } return ImmediateFuture.newInstance(new RestfulCollection<Activity>(osActivities)); } @Inject  ActivityServiceImpl(@Named("getUserActivities") final ServiceAction inGetUserActivitiesAction,
            @Named("deleteUserActivities") final TaskHandlerAction inDeleteActivitiesAction,
            final ActionController inServiceActionController,
            @Named("openSocialPrincipalDao") final DomainMapper<String, Principal> inOpenSocialPrincipalDao,
            @Named("postPersonActivityServiceActionTaskHandler") final TaskHandlerServiceAction inPostActivityAction,
            @Named("jpaGadgetDefinitionMapper") final GadgetDefinitionMapper inGadgetDefinitionMapper,
            final GadgetMetaDataFetcher inGadgetMetaDataFetcher); Future<Void> createActivity(final UserId userId, final GroupId groupId, final String appId,
            final Set<String> fields, final Activity activity, final SecurityToken token); Future<Void> deleteActivities(final UserId userId, final GroupId groupId, final String appId,
            final Set<String> activityIds, final SecurityToken token); @SuppressWarnings("unchecked") Future<RestfulCollection<Activity>> getActivities(final Set<UserId> userIds, final GroupId groupId,
            final String appId, final Set<String> fields, final CollectionOptions options, final SecurityToken token); @SuppressWarnings("unchecked") Future<RestfulCollection<Activity>> getActivities(final UserId userId, final GroupId groupId,
            final String appId, final Set<String> fields, final CollectionOptions options,
            final Set<String> activityIds, final SecurityToken token); Future<Activity> getActivity(final UserId userId, final GroupId groupId, final String appId,
            final Set<String> fields, final String activityId, final SecurityToken token); }
ActivityServiceImpl implements ActivityService { @SuppressWarnings("unchecked") public Future<RestfulCollection<Activity>> getActivities(final Set<UserId> userIds, final GroupId groupId, final String appId, final Set<String> fields, final CollectionOptions options, final SecurityToken token) { log.trace("Entering getActivities"); List<Activity> osActivities = new ArrayList<Activity>(); try { Set<String> userIdList = new HashSet<String>(); for (UserId currentUserId : userIds) { if (!currentUserId.getUserId(token).equals("null")) { userIdList.add(currentUserId.getUserId(token)); } } log.debug("Sending getActivities userIdList to action: " + userIdList.toString()); GetUserActivitiesRequest currentRequest = new GetUserActivitiesRequest(new ArrayList<Long>(), userIdList); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, openSocialPrincipalDao.execute(token.getViewerId())); LinkedList<ActivityDTO> activities = (LinkedList<ActivityDTO>) serviceActionController.execute( currentContext, getUserActivitiesAction); log.debug("Retrieved " + activities.size() + " activities from action"); for (ActivityDTO currentActivity : activities) { osActivities.add(convertActivityFromEurekaActivityDTOToOS(currentActivity)); } } catch (Exception ex) { log.error("Error occurred retrieving activities ", ex); throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); } return ImmediateFuture.newInstance(new RestfulCollection<Activity>(osActivities)); } @Inject  ActivityServiceImpl(@Named("getUserActivities") final ServiceAction inGetUserActivitiesAction,
            @Named("deleteUserActivities") final TaskHandlerAction inDeleteActivitiesAction,
            final ActionController inServiceActionController,
            @Named("openSocialPrincipalDao") final DomainMapper<String, Principal> inOpenSocialPrincipalDao,
            @Named("postPersonActivityServiceActionTaskHandler") final TaskHandlerServiceAction inPostActivityAction,
            @Named("jpaGadgetDefinitionMapper") final GadgetDefinitionMapper inGadgetDefinitionMapper,
            final GadgetMetaDataFetcher inGadgetMetaDataFetcher); Future<Void> createActivity(final UserId userId, final GroupId groupId, final String appId,
            final Set<String> fields, final Activity activity, final SecurityToken token); Future<Void> deleteActivities(final UserId userId, final GroupId groupId, final String appId,
            final Set<String> activityIds, final SecurityToken token); @SuppressWarnings("unchecked") Future<RestfulCollection<Activity>> getActivities(final Set<UserId> userIds, final GroupId groupId,
            final String appId, final Set<String> fields, final CollectionOptions options, final SecurityToken token); @SuppressWarnings("unchecked") Future<RestfulCollection<Activity>> getActivities(final UserId userId, final GroupId groupId,
            final String appId, final Set<String> fields, final CollectionOptions options,
            final Set<String> activityIds, final SecurityToken token); Future<Activity> getActivity(final UserId userId, final GroupId groupId, final String appId,
            final Set<String> fields, final String activityId, final SecurityToken token);  }