@Before public void setUp() throws Exception { token = new FakeGadgetToken(); messageService = EasyMock.createMock(MessageService.class); messageService = EasyMock.createMock(MessageService.class); converter = EasyMock.createMock(BeanJsonConverter.class); sender = new UserId(UserId.Type.userId, "message.sender"); recipients = ImmutableList.of("second.recipient", "first.recipient"); handler = new MessageHandler(messageService, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
@Operation(httpMethods = "GET") public Future<?> get(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); CollectionOptions options = collectionOptionsFactory.create(request); // Preconditions HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Only one userId must be specified"); return service.getGroups(userIds.iterator().next(), options, request.getFields(), request.getToken()); } }
@Operation(httpMethods = "GET") public Future<?> get(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); CollectionOptions options = collectionOptionsFactory.create(request); // Preconditions HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Only one userId must be specified"); return service.getGroups(userIds.iterator().next(), options, request.getFields(), request.getToken()); } }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); messageService = EasyMock.createMock(MessageService.class); messageService = EasyMock.createMock(MessageService.class); converter = EasyMock.createMock(BeanJsonConverter.class); sender = new UserId(UserId.Type.userId, "message.sender"); recipients = ImmutableList.of("second.recipient", "first.recipient"); handler = new MessageHandler(messageService, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
return service.getMediaItems(Iterables.getOnlyElement(userIds), request.getAppId(), albumId, optionalMediaItemIds, request.getFields(), collectionOptionsFactory.create(request), request.getToken()); return service.getMediaItems(Iterables.getOnlyElement(userIds), request.getAppId(), albumId, request.getFields(), collectionOptionsFactory.create(request), request.getToken()); collectionOptionsFactory.create(request), request.getToken());
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = new BeanJsonConverter(Guice.createInjector()); mediaService = mock(MediaItemService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {mediaItem: ['id', 'language', 'title']}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new MediaItemHandler(mediaService, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); request = new SocialRequestItem( Maps.<String, String[]>newHashMap(), token, converter, converter); }
@Operation(httpMethods = "GET") public Future<?> get(SocialRequestItem request) throws ProtocolException { // Get user, group, and album IDs Set<UserId> userIds = request.getUsers(); Set<String> optionalAlbumIds = ImmutableSet.copyOf(request .getListParameter("albumId")); // At least one userId must be specified HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); // If multiple userIds specified, albumIds must not be specified if (userIds.size() > 1 && !optionalAlbumIds.isEmpty()) { throw new IllegalArgumentException("Cannot fetch same albumIds for multiple userIds"); } // Retrieve albums by ID if (!optionalAlbumIds.isEmpty()) { if (optionalAlbumIds.size() == 1) { return service.getAlbum(Iterables.getOnlyElement(userIds), request.getAppId(), request.getFields(), optionalAlbumIds.iterator().next(), request.getToken()); } else { return service.getAlbums(Iterables.getOnlyElement(userIds), request.getAppId(), request.getFields(), collectionOptionsFactory.create(request), optionalAlbumIds, request.getToken()); } } // Retrieve albums by group return service.getAlbums(userIds, request.getGroup(), request .getAppId(), request.getFields(), collectionOptionsFactory.create(request), request.getToken()); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = new BeanJsonConverter(Guice.createInjector()); mediaService = mock(MediaItemService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {mediaItem: ['id', 'language', 'title']}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new MediaItemHandler(mediaService, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); request = new SocialRequestItem( Maps.<String, String[]>newHashMap(), token, converter, converter); }
@Operation(httpMethods = "GET") public Future<?> get(SocialRequestItem request) throws ProtocolException { // Get user, group, and album IDs Set<UserId> userIds = request.getUsers(); Set<String> optionalAlbumIds = ImmutableSet.copyOf(request .getListParameter("albumId")); // At least one userId must be specified HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); // If multiple userIds specified, albumIds must not be specified if (userIds.size() > 1 && !optionalAlbumIds.isEmpty()) { throw new IllegalArgumentException("Cannot fetch same albumIds for multiple userIds"); } // Retrieve albums by ID if (!optionalAlbumIds.isEmpty()) { if (optionalAlbumIds.size() == 1) { return service.getAlbum(Iterables.getOnlyElement(userIds), request.getAppId(), request.getFields(), optionalAlbumIds.iterator().next(), request.getToken()); } else { return service.getAlbums(Iterables.getOnlyElement(userIds), request.getAppId(), request.getFields(), collectionOptionsFactory.create(request), optionalAlbumIds, request.getToken()); } } // Retrieve albums by group return service.getAlbums(userIds, request.getGroup(), request .getAppId(), request.getFields(), collectionOptionsFactory.create(request), request.getToken()); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = mock(BeanJsonConverter.class); albumService = mock(AlbumService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {album: ['id', 'title', 'location']}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new AlbumHandler(albumService, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
return service.getMediaItems(Iterables.getOnlyElement(userIds), request.getAppId(), albumId, optionalMediaItemIds, request.getFields(), collectionOptionsFactory.create(request), request.getToken()); return service.getMediaItems(Iterables.getOnlyElement(userIds), request.getAppId(), albumId, request.getFields(), collectionOptionsFactory.create(request), request.getToken()); collectionOptionsFactory.create(request), request.getToken());
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = mock(BeanJsonConverter.class); personService = mock(PersonService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {person: ['id', {name: 'familyName'}]}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new PersonHandler(personService, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
Set<String> optionalActivityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); CollectionOptions options = collectionOptionsFactory.create(request);
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = mock(BeanJsonConverter.class); albumService = mock(AlbumService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {album: ['id', 'title', 'location']}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new AlbumHandler(albumService, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
Set<String> optionalActivityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); CollectionOptions options = collectionOptionsFactory.create(request);
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); converter = mock(BeanJsonConverter.class); personService = mock(PersonService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {person: ['id', {name: 'familyName'}]}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new PersonHandler(personService, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
Set<String> optionalActivityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); CollectionOptions options = collectionOptionsFactory.create(request);
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); token.setAppId("appId"); converter = mock(BeanJsonConverter.class); activityService = mock(ActivityService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {activity: ['id', 'title']}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new ActivityHandler(activityService, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
Set<String> optionalActivityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); CollectionOptions options = collectionOptionsFactory.create(request);
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); token.setAppId("appId"); converter = mock(BeanJsonConverter.class); service = mock(ActivityStreamService.class); JSONObject config = new JSONObject('{' + ContainerConfig.DEFAULT_CONTAINER + ':' + "{'gadgets.container': ['default']," + "'gadgets.features':{opensocial:" + "{supportedFields: {activityEntry: ['id', 'title']}}" + "}}}"); containerConfig = new JsonContainerConfig(config, Expressions.forTesting()); handler = new ActivityStreamHandler(service, containerConfig, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }