use of com.instructure.canvasapi.model.Conversation in project instructure-android by instructure.
the class ConversationUnitTest method testConversation.
@Test
public void testConversation() {
Gson gson = CanvasRestAdapter.getGSONParser();
// We have a list json and a detailed json
Conversation[] tempConversations = gson.fromJson(conversationArrayJSON, Conversation[].class);
Conversation detailedConversation = gson.fromJson(detailedConversationJSON, Conversation.class);
// merge the two together
ArrayList<Conversation> conversations = new ArrayList<Conversation>(Arrays.asList(tempConversations));
conversations.add(detailedConversation);
assertNotNull(conversations);
assertEquals(6, conversations.size());
for (Conversation conversation : conversations) {
assertNotNull(conversation);
assertNotNull(conversation.getAllParticipants());
for (BasicUser basicUser : conversation.getAllParticipants()) {
assertNotNull(basicUser);
assertTrue(basicUser.getId() > 0);
assertNotNull(basicUser.getUsername());
}
assertTrue(conversation.getId() > 0);
assertNotNull(conversation.getAudienceIDs());
assertNotNull(conversation.getAvatarURL());
assertNotNull(conversation.getLastMessagePreview());
assertNotNull(conversation.getLastMessageSent());
assertTrue(conversation.getMessageCount() > 0);
if (conversation.getMessages() != null) {
for (Message message : conversation.getMessages()) {
testMessage(message);
}
}
assertFalse(conversation.getWorkflowState() == Conversation.WorkflowState.UNKNOWN);
}
}