Search in sources :

Example 1 with LockInfo

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

the class AssignmentUnitTest method testLockedAssignment.

@Test
public void testLockedAssignment() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    Assignment lockInfoAssignment = gson.fromJson(lockInfoJSON, Assignment.class);
    // If the assignment is locked for the user, make sure the lock_info & explanation aren't empty/null
    if (lockInfoAssignment.isLockedForUser()) {
        assertTrue(!lockInfoAssignment.getLockInfo().isEmpty());
        assertNotNull(lockInfoAssignment.getLock_explanation());
    }
    LockInfo lockInfo = lockInfoAssignment.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(9, completionRequirements.size());
    for (ModuleCompletionRequirement requirement : completionRequirements) {
        assertNotNull(requirement.getId());
        assertNotNull(requirement.getType());
    }
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) LockedModule(com.instructure.canvasapi.model.LockedModule) Gson(com.google.gson.Gson) LockInfo(com.instructure.canvasapi.model.LockInfo) ModuleCompletionRequirement(com.instructure.canvasapi.model.ModuleCompletionRequirement) Test(org.junit.Test)

Example 2 with LockInfo

use of com.instructure.canvasapi.model.LockInfo 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)

Aggregations

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