Search in sources :

Example 86 with Course

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());
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Bundle(android.os.Bundle) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 87 with Course

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);
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 88 with Course

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());
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Bundle(android.os.Bundle) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 89 with Course

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());
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Bundle(android.os.Bundle) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 90 with Course

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);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Aggregations

Course (com.instructure.canvasapi2.models.Course)106 Test (org.junit.Test)70 ArrayList (java.util.ArrayList)39 Enrollment (com.instructure.canvasapi2.models.Enrollment)29 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)17 RestParams (com.instructure.canvasapi2.builders.RestParams)17 View (android.view.View)13 Bundle (android.os.Bundle)10 TextView (android.widget.TextView)10 NonNull (android.support.annotation.NonNull)8 AdapterView (android.widget.AdapterView)8 ModuleItem (com.instructure.canvasapi2.models.ModuleItem)8 ParentFragment (com.instructure.candroid.fragment.ParentFragment)7 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)7 ImageView (android.widget.ImageView)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)6 List (java.util.List)6 BindView (butterknife.BindView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 StatusCallback (com.instructure.canvasapi2.StatusCallback)4