use of codeu.model.data.Conversation in project codeu-2018-team12 by codeu-2018-team12.
the class ConversationStoreTest method testAddConversation.
@Test
public void testAddConversation() {
Conversation inputConversation = new Conversation(UUID.randomUUID(), UUID.randomUUID(), "test_conversation", Instant.now());
conversationStore.addConversation(inputConversation);
Conversation resultConversation = conversationStore.getConversationWithTitle("test_conversation");
assertEquals(inputConversation, resultConversation);
Mockito.verify(mockPersistentStorageAgent).writeThrough(inputConversation);
}
use of codeu.model.data.Conversation in project codeu-2018-team12 by codeu-2018-team12.
the class ConversationStoreTest method testGetConversationWithId_found.
@Test
public void testGetConversationWithId_found() {
Conversation resultConversation = conversationStore.getConversationWithId(CONVERSATION_ONE.getId());
assertEquals(CONVERSATION_ONE, resultConversation);
}
use of codeu.model.data.Conversation in project codeu-2018-team12 by codeu-2018-team12.
the class PersistentStorageAgentTest method testUpdateEntityConversationUser.
@Test
public void testUpdateEntityConversationUser() {
Conversation conversation = new Conversation(UUID.randomUUID(), UUID.randomUUID(), "test_conversation", Instant.now());
persistentStorageAgent.updateConversationEntityUsers(conversation);
Mockito.verify(mockPersistentDataStore).updateConversationEntityUsers(conversation);
}
use of codeu.model.data.Conversation in project codeu-2018-team12 by codeu-2018-team12.
the class ChatServletTest method testDoPost_StoresActivity.
@Test
public void testDoPost_StoresActivity() throws IOException, ServletException {
Mockito.when(mockRequest.getRequestURI()).thenReturn("/chat/test_conversation");
Mockito.when(mockSession.getAttribute("user")).thenReturn("test_username");
User fakeUser = new User(UUID.randomUUID(), "test_username", "password", "testbiography", Instant.now(), "codeUChatTestEmail@gmail.com");
Mockito.when(mockUserStore.getUser("test_username")).thenReturn(fakeUser);
Conversation fakeConversation = new Conversation(UUID.randomUUID(), UUID.randomUUID(), "test_conversation", Instant.now());
Mockito.when(mockConversationStore.getConversationWithTitle("test_conversation")).thenReturn(fakeConversation);
fakeConversation.getConversationUsers().add(fakeUser.getId());
Mockito.when(mockRequest.getParameter("submitText")).thenReturn("submitText");
Mockito.when(mockRequest.getParameter("message")).thenReturn("Test message.");
Activity activity = new Activity(UUID.randomUUID(), fakeUser.getId(), fakeConversation.getId(), Instant.now(), "sentMessage", "test_activity_message" + "Test message.", fakeConversation.getConversationUsers(), fakeConversation.getIsPublic());
mockActivityStore.addActivity(activity);
Mockito.when(mockActivityStore.getActivityWithId(activity.getId())).thenReturn(activity);
chatServlet.doPost(mockRequest, mockResponse);
ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
Mockito.verify(mockMessageStore).addMessage(messageArgumentCaptor.capture());
Mockito.verify(mockActivityStore).addActivity(activity);
Assert.assertEquals("Test message.", messageArgumentCaptor.getValue().getContent());
Assert.assertTrue(mockActivityStore.getActivityWithId(activity.getId()).getActivityMessage().contains("Test message."));
Mockito.verify(mockResponse).sendRedirect("/chat/test_conversation");
}
use of codeu.model.data.Conversation in project codeu-2018-team12 by codeu-2018-team12.
the class ChatServletTest method testDoPost_UserNotJoinedConversation.
@Test
public void testDoPost_UserNotJoinedConversation() throws IOException, ServletException {
Mockito.when(mockRequest.getRequestURI()).thenReturn("/chat/test_conversation");
Mockito.when(mockSession.getAttribute("user")).thenReturn("test_username");
User fakeUser = new User(UUID.randomUUID(), "test_username", "password", "testbio", Instant.now(), "codeUChatTestEmail@gmail.com");
Mockito.when(mockUserStore.getUser("test_username")).thenReturn(fakeUser);
Conversation fakeConversation = new Conversation(UUID.randomUUID(), UUID.randomUUID(), "test_conversation", Instant.now());
Mockito.when(mockConversationStore.getConversationWithTitle("test_conversation")).thenReturn(fakeConversation);
chatServlet.doPost(mockRequest, mockResponse);
Mockito.verify(mockMessageStore, Mockito.never()).addMessage(Mockito.any(Message.class));
Mockito.verify(mockResponse).sendRedirect("/chat/test_conversation");
}
Aggregations