/** * Allowed end-points /activities/{userId}/@self/{actvityId}+ * * examples: /activities/john.doe/@self/1 */ @Operation(httpMethods="DELETE") public Future<?> delete(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); Set<String> activityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); // Throws exceptions if userIds contains more than one element or zero elements return service.deleteActivities(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), activityIds, request.getToken()); }
/** * Allowed end-points /activities/{userId}/@self/{actvityId}+ * * examples: /activities/john.doe/@self/1 */ @Operation(httpMethods="DELETE") public Future<?> delete(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); Set<String> activityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); // Throws exceptions if userIds contains more than one element or zero elements return service.deleteActivities(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), activityIds, request.getToken()); }
/** * Allowed end-points /activities/{userId}/@self/{actvityId}+ * * examples: /activities/john.doe/@self/1 */ @Operation(httpMethods="DELETE") public Future<?> delete(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); Set<String> activityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); // Throws exceptions if userIds contains more than one element or zero elements return service.deleteActivities(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), activityIds, request.getToken()); }
@Test public void testHandleDelete() throws Exception { String path = "/activities/john.doe/@self/@app/1"; RestHandler operation = registry.getRestHandler(path, "DELETE"); org.easymock.EasyMock.expect(activityService.deleteActivities(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.of("1")), eq(token))).andReturn(Futures.immediateFuture((Void) null)); replay(); assertNull(operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
@Test public void testHandleDelete() throws Exception { String path = "/activities/john.doe/@self/@app/1"; RestHandler operation = registry.getRestHandler(path, "DELETE"); org.easymock.EasyMock.expect(activityService.deleteActivities(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.of("1")), eq(token))).andReturn(Futures.immediateFuture((Void) null)); replay(); assertNull(operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
@Test public void testHandleDelete() throws Exception { String path = "/activities/john.doe/@self/@app/1"; RestHandler operation = registry.getRestHandler(path, "DELETE"); org.easymock.EasyMock.expect(activityService.deleteActivities(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.of("1")), eq(token))).andReturn(ImmediateFuture.newInstance((Void) null)); replay(); assertNull(operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }