@Test @Ignore public void testPostMessage() throws Exception { MessageImpl message = new MessageImpl("A message body", "A title", Message.Type.PRIVATE_MESSAGE); message.setRecipients(recipients); EasyMock.expect(converter.convertToObject(null, Message.class)).andReturn(message); EasyMock.expect(messageService.createMessage(sender, "messageHandlerTest", "@outbox", message, token)).andReturn(Futures.immediateFuture((Void) null)); EasyMock.replay(messageService, converter); RestHandler operation = registry.getRestHandler("/messages/" + sender.getUserId() + "/@outbox", "POST"); Map<String,String[]> params = ImmutableMap.of(RequestItem.APP_ID, new String[]{"messageHandlerTest"}); operation.execute(params,null, token, converter).get(); EasyMock.verify(converter, messageService); } }
@Test public void testCreateMessage() throws Exception { // Create a new private message Message msg = new MessageImpl(); msg.setBody("Hello"); msg.setRecipients(Collections.singletonList(JANE_DOE.getUserId())); db.createMessage(JOHN_DOE, APP_ID, "privateMessage", msg, token).get(); // Check that the message was created RestfulCollection<Message> messages = db.getMessages( JANE_DOE, "privateMessage", Collections.<String>emptySet(), Collections.<String>singletonList(msg.getId()), new CollectionOptions(), token).get(); assertEquals(1, messages.getList().size()); } }
@Test public void testCreateMessage() throws Exception { // Create a new private message Message msg = new MessageImpl(); msg.setBody("Hello"); msg.setRecipients(Collections.singletonList(JANE_DOE.getUserId())); db.createMessage(JOHN_DOE, APP_ID, "privateMessage", msg, token).get(); // Check that the message was created RestfulCollection<Message> messages = db.getMessages( JANE_DOE, "privateMessage", Collections.<String>emptySet(), Collections.<String>singletonList(msg.getId()), new CollectionOptions(), token).get(); assertEquals(1, messages.getList().size()); } }
@Test public void testPostMessage() throws Exception { MessageImpl message = new MessageImpl("A message body", "A title", Message.Type.PRIVATE_MESSAGE); message.setRecipients(recipients); EasyMock.expect(converter.convertToObject(null, Message.class)).andReturn(message); EasyMock.expect(messageService.createMessage(sender, "messageHandlerTest", "@outbox", message, token)).andReturn(ImmediateFuture.newInstance((Void) null)); EasyMock.replay(messageService, converter); RestHandler operation = registry.getRestHandler("/messages/" + sender.getUserId() + "/@outbox", "POST"); Map<String,String[]> params = ImmutableMap.of(RequestItem.APP_ID, new String[]{"messageHandlerTest"}); operation.execute(params,null, token, converter).get(); EasyMock.verify(converter, messageService); } }
@Test @Ignore public void testPostMessage() throws Exception { MessageImpl message = new MessageImpl("A message body", "A title", Message.Type.PRIVATE_MESSAGE); message.setRecipients(recipients); EasyMock.expect(converter.convertToObject(null, Message.class)).andReturn(message); EasyMock.expect(messageService.createMessage(sender, "messageHandlerTest", "@outbox", message, token)).andReturn(Futures.immediateFuture((Void) null)); EasyMock.replay(messageService, converter); RestHandler operation = registry.getRestHandler("/messages/" + sender.getUserId() + "/@outbox", "POST"); Map<String,String[]> params = ImmutableMap.of(RequestItem.APP_ID, new String[]{"messageHandlerTest"}); operation.execute(params,null, token, converter).get(); EasyMock.verify(converter, messageService); } }