Search in sources :

Example 1 with DiscussionTopicHeader

use of com.instructure.canvasapi.model.DiscussionTopicHeader in project instructure-android by instructure.

the class DiscussionTopicHeaderUnitTest method testLockedDiscussionTopic.

@Test
public void testLockedDiscussionTopic() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    DiscussionTopicHeader lockedDiscussion = gson.fromJson(lockedDiscussionTopicJSON, DiscussionTopicHeader.class);
    // If the DiscussionTopic is locked for the user, make sure the lock_info & explanation aren't empty/null
    if (lockedDiscussion.isLockedForUser()) {
        assertTrue(!lockedDiscussion.getLockInfo().isEmpty());
        assertNotNull(lockedDiscussion.getLockExplanation());
    }
    LockInfo lockInfo = lockedDiscussion.getLockInfo();
    assertNotNull(lockInfo);
    // The lock_info should have a context_module
    LockedModule lockedModule = lockInfo.getContext_module();
    assertNotNull(lockedModule);
    assertNotNull(lockedModule.getId());
    assertNotNull(lockedModule.getContext_id());
    assertNotNull(lockedModule.getContextType());
    assertNotNull(lockedModule.getName());
    assertNotNull(lockedModule.getUnlock_at());
    assertNotNull(lockedModule.isRequireSequentialProgress());
    List<ModuleCompletionRequirement> completionRequirements = lockedModule.getCompletionRequirements();
    assertNotNull(completionRequirements);
    assertEquals(3, completionRequirements.size());
    for (ModuleCompletionRequirement requirement : completionRequirements) {
        assertNotNull(requirement.getId());
        assertNotNull(requirement.getType());
    }
}
Also used : LockedModule(com.instructure.canvasapi.model.LockedModule) Gson(com.google.gson.Gson) DiscussionTopicHeader(com.instructure.canvasapi.model.DiscussionTopicHeader) LockInfo(com.instructure.canvasapi.model.LockInfo) ModuleCompletionRequirement(com.instructure.canvasapi.model.ModuleCompletionRequirement) Test(org.junit.Test)

Example 2 with DiscussionTopicHeader

use of com.instructure.canvasapi.model.DiscussionTopicHeader in project instructure-android by instructure.

the class DiscussionTopicHeaderUnitTest method testDiscussionTopicHeader.

@Test
public void testDiscussionTopicHeader() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    DiscussionTopicHeader discussionTopicHeader = gson.fromJson(discussionTopicHeaderJSON, DiscussionTopicHeader.class);
    assertNotNull(discussionTopicHeader);
    assertTrue(discussionTopicHeader.isPinned());
    assertTrue(discussionTopicHeader.getStatus() == DiscussionTopicHeader.ReadState.UNREAD);
    assertTrue(discussionTopicHeader.getId() > 0);
    assertTrue(discussionTopicHeader.getAssignmentId() > 0);
    assertNotNull(discussionTopicHeader.getCreator());
    assertNotNull(discussionTopicHeader.getHtmlUrl());
    assertNotNull(discussionTopicHeader.getLastReply());
    assertNotNull(discussionTopicHeader.getMessage());
    assertNotNull(discussionTopicHeader.getMessage());
    assertNotNull(discussionTopicHeader.getPostedAt());
    assertNotNull(discussionTopicHeader.getTitle());
    assertTrue(discussionTopicHeader.getType() == DiscussionTopicHeader.DiscussionType.SIDE_COMMENT);
    testDiscussionParticipant(discussionTopicHeader.getCreator());
    testDiscussionAttachments(discussionTopicHeader.getAttachments());
    testDiscussionPermissions(discussionTopicHeader.getPermission());
}
Also used : Gson(com.google.gson.Gson) DiscussionTopicHeader(com.instructure.canvasapi.model.DiscussionTopicHeader) Test(org.junit.Test)

Aggregations

Gson (com.google.gson.Gson)2 DiscussionTopicHeader (com.instructure.canvasapi.model.DiscussionTopicHeader)2 Test (org.junit.Test)2 LockInfo (com.instructure.canvasapi.model.LockInfo)1 LockedModule (com.instructure.canvasapi.model.LockedModule)1 ModuleCompletionRequirement (com.instructure.canvasapi.model.ModuleCompletionRequirement)1