private Future<?> setupBodyRequest(String method) throws ProtocolException { String jsonActivity = "{title: hi mom!, etc etc}"; String path = "/activities/john.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, method); Activity activity = new ActivityImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivity), eq(Activity.class))) .andReturn(activity); org.easymock.EasyMock.expect(activityService.createActivity(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(activity), eq(token))).andReturn(Futures.immediateFuture((Void) null)); replay(); return operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivity), token, converter); }
private Future<?> setupBodyRequest(String method) throws ProtocolException { String jsonActivity = "{title: hi mom!, etc etc}"; String path = "/activities/john.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, method); Activity activity = new ActivityImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivity), eq(Activity.class))) .andReturn(activity); org.easymock.EasyMock.expect(activityService.createActivity(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(activity), eq(token))).andReturn(Futures.immediateFuture((Void) null)); replay(); return operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivity), token, converter); }
/** * Allowed end-points /activities/{userId}/@self * * examples: /activities/john.doe/@self - postBody is an activity object */ @Operation(httpMethods="POST", bodyParam = "activity") public Future<?> create(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); List<String> activityIds = request.getListParameter("activityId"); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); // TODO(lryan) This seems reasonable to allow on PUT but we don't have an update verb. HandlerPreconditions.requireEmpty(activityIds, "Cannot specify activityId in create"); return service.createActivity(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), request.getFields(), request.getTypedParameter("activity", Activity.class), request.getToken()); }
private Future<?> setupBodyRequest(String method) throws ProtocolException { String jsonActivity = "{title: hi mom!, etc etc}"; String path = "/activities/john.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, method); Activity activity = new ActivityImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivity), eq(Activity.class))) .andReturn(activity); org.easymock.EasyMock.expect(activityService.createActivity(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(activity), eq(token))).andReturn(ImmediateFuture.newInstance((Void) null)); replay(); return operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivity), token, converter); }
/** * Allowed end-points /activities/{userId}/@self * * examples: /activities/john.doe/@self - postBody is an activity object */ @Operation(httpMethods="POST", bodyParam = "activity") public Future<?> create(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); List<String> activityIds = request.getListParameter("activityId"); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); // TODO(lryan) This seems reasonable to allow on PUT but we don't have an update verb. HandlerPreconditions.requireEmpty(activityIds, "Cannot specify activityId in create"); return service.createActivity(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), request.getFields(), request.getTypedParameter("activity", Activity.class), request.getToken()); }
/** * Allowed end-points /activities/{userId}/@self * * examples: /activities/john.doe/@self - postBody is an activity object */ @Operation(httpMethods="POST", bodyParam = "activity") public Future<?> create(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); List<String> activityIds = request.getListParameter("activityId"); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); // TODO(lryan) This seems reasonable to allow on PUT but we don't have an update verb. HandlerPreconditions.requireEmpty(activityIds, "Cannot specify activityId in create"); return service.createActivity(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), request.getFields(), request.getTypedParameter("activity", Activity.class), request.getToken()); }