use of com.instructure.canvasapi.model.Message 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);
}
}
use of com.instructure.canvasapi.model.Message in project instructure-android by instructure.
the class ConversationUnitTest method testMessage.
// Gets tested from testConversation()
public static void testMessage(Message message) {
assertNotNull(message);
if (message.getAttachments() != null) {
for (Attachment attachment : message.getAttachments()) {
assertNotNull(attachment);
assertTrue(attachment.getId() > 0);
assertNotNull(attachment.getDisplayName());
assertNotNull(attachment.getFilename());
assertNotNull(attachment.getMimeType());
assertNotNull(attachment.getUrl());
}
}
assertTrue(message.getAuthorID() > 0);
assertNotNull(message.getBody());
assertNotNull(message.getCreationDate());
assertTrue(message.getId() > 0);
if (message.getForwardedMessages() != null) {
for (Message replyMessage : message.getForwardedMessages()) {
testMessage(replyMessage);
}
}
}
Aggregations