ChatRoomAction implements Serializable { @Transactional public void chat(){ Chat chat = new Chat(); chat.setContent(chatRoom.getContent().trim()); chat.setRoom(auth.getSelected()); chat.setSpeaker(auth.getAccount()); Timestamp now = new Timestamp(System.currentTimeMillis()); chat.setPosted(now); service.addChat(chat); chatRoom.setContent(""); notify.notifyNewChat(); }  void prepareRoom(); void selectRoom(Room room); @Transactional void chat(); void refreshChat(); ChatRoom getChatRoom();  }
@Test @InRequestScope public void testChat() throws Exception{ setUp(); target.getChatRoom().setContent("chat"); target.chat(); assertThat(target.getChatRoom().getChats().size(), is(1)); assertThat(target.getChatRoom().getChats().get(0).getContent(), is("chat")); assertThat(target.getChatRoom().getLastPost(), notNullValue()); }