use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_quiz.
@Test
public void testGetFragment_quiz() {
String url = "https://mobile.canvas.net/api/v1/courses/222/quizzes/123456789";
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("Quiz");
moduleItem.setId(4567);
moduleItem.setUrl(url);
Course course = new Course();
String htmlUrl = "https://mobile.canvas.net/courses/222/quizzes/123456789";
String apiUrl = "courses/222/quizzes/123456789";
moduleItem.setHtml_url(htmlUrl);
Bundle expectedBundle = new Bundle();
expectedBundle.putSerializable(Const.CANVAS_CONTEXT, course);
expectedBundle.putString(Const.URL, htmlUrl);
expectedBundle.putString(Const.API_URL, apiUrl);
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNotNull(parentFragment);
assertEquals(ModuleQuizDecider.class, parentFragment.getClass());
assertEquals(expectedBundle.toString(), parentFragment.getArguments().toString());
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_subheader.
@Test
public void testGetFragment_subheader() {
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("SubHeader");
Course course = new Course();
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNull(parentFragment);
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_assignment.
@Test
public void testGetFragment_assignment() {
String url = "https://mobile.canvas.net/api/v1/courses/222/assignments/123456789";
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("Assignment");
moduleItem.setId(4567);
moduleItem.setUrl(url);
Course course = new Course();
Bundle expectedBundle = new Bundle();
expectedBundle.putSerializable(Const.CANVAS_CONTEXT, course);
expectedBundle.putLong(Const.ASSIGNMENT_ID, 123456789);
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNotNull(parentFragment);
assertEquals(AssignmentFragment.class, parentFragment.getClass());
assertEquals(expectedBundle.toString(), parentFragment.getArguments().toString());
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_discussion.
@Test
public void testGetFragment_discussion() {
String url = "https://mobile.canvas.net/api/v1/courses/222/discussion_topics/123456789";
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("Discussion");
moduleItem.setId(4567);
moduleItem.setUrl(url);
Course course = new Course();
Bundle expectedBundle = new Bundle();
expectedBundle.putSerializable(Const.CANVAS_CONTEXT, course);
expectedBundle.putLong(Const.TOPIC_ID, 123456789);
expectedBundle.putBoolean(Const.ANNOUNCEMENT, false);
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNotNull(parentFragment);
assertEquals(DiscussionDetailsFragment.class, parentFragment.getClass());
assertEquals(expectedBundle.toString(), parentFragment.getArguments().toString());
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class CourseAPI method getNextPageCourses.
public static void getNextPageCourses(boolean forceNetwork, String nextUrl, RestBuilder adapter, StatusCallback<List<Course>> callback) {
RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
callback.addCall(adapter.build(CoursesInterface.class, params).next(nextUrl)).enqueue(callback);
}
Aggregations