Search in sources :

Example 1 with Conversation

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);
    }
}
Also used : BasicUser(com.instructure.canvasapi.model.BasicUser) Message(com.instructure.canvasapi.model.Message) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) Conversation(com.instructure.canvasapi.model.Conversation) Test(org.junit.Test)

Aggregations

Gson (com.google.gson.Gson)1 BasicUser (com.instructure.canvasapi.model.BasicUser)1 Conversation (com.instructure.canvasapi.model.Conversation)1 Message (com.instructure.canvasapi.model.Message)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1