Search in sources :

Example 6 with Route

use of com.instructure.interactions.router.Route in project instructure-android by instructure.

the class RouteTest method testRouteNoParams.

// endregion
// region Params
@Test
public void testRouteNoParams() {
    HashMap<String, String> expectedParams = new HashMap<>();
    Route route = new Route("/courses");
    assertTrue(route.apply("http://mobiledev.instructure.com/courses/"));
    assertEquals(expectedParams, route.getParamsHash());
    // no slash at the end
    assertTrue(route.apply("http://mobiledev.instructure.com/courses/"));
    assertEquals(expectedParams, route.getParamsHash());
}
Also used : HashMap(java.util.HashMap) Route(com.instructure.interactions.router.Route) Test(org.junit.Test)

Example 7 with Route

use of com.instructure.interactions.router.Route in project instructure-android by instructure.

the class RouteTest method testRouteTwoCharParam.

@Test
public void testRouteTwoCharParam() {
    HashMap<String, String> expectedParams = new HashMap<>();
    expectedParams.put("course_id", "833052");
    expectedParams.put("page_id", "page-3");
    Route route = new Route("/courses/:course_id/pages/:page_id");
    assertTrue(route.apply("https://mobiledev.instructure.com/courses/833052/pages/page-3/"));
    assertEquals(expectedParams, route.getParamsHash());
}
Also used : HashMap(java.util.HashMap) Route(com.instructure.interactions.router.Route) Test(org.junit.Test)

Example 8 with Route

use of com.instructure.interactions.router.Route in project instructure-android by instructure.

the class RouteTest method testRouteThreeIntParams.

@Test
public void testRouteThreeIntParams() {
    HashMap<String, String> expectedParams = new HashMap<>();
    expectedParams.put("course_id", "953090");
    expectedParams.put("assignment_id", "2651861");
    expectedParams.put("submission_id", "3690827");
    Route route = new Route("/(?:courses|groups)/:course_id/assignments/:assignment_id/submissions/:submission_id");
    assertTrue(route.apply("http://mobiledev.instructure.com/courses/953090/assignments/2651861/submissions/3690827/"));
    assertEquals(expectedParams, route.getParamsHash());
    // no slash at the end
    assertTrue(route.apply("http://mobiledev.instructure.com/courses/953090/assignments/2651861/submissions/3690827"));
    assertEquals(expectedParams, route.getParamsHash());
}
Also used : HashMap(java.util.HashMap) Route(com.instructure.interactions.router.Route) Test(org.junit.Test)

Example 9 with Route

use of com.instructure.interactions.router.Route in project instructure-android by instructure.

the class RouteTest method testRouteQueryParams.

// endregion
// region Query Params
@Test
public void testRouteQueryParams() {
    HashMap<String, String> expectedParams = new HashMap<>();
    expectedParams.put("course_id", "836357");
    expectedParams.put("quiz_id", "990775");
    Route route = new Route("/courses/:course_id/quizzes/:quiz_id");
    assertTrue(route.apply("https://mobiledev.instructure.com/courses/836357/quizzes/990775?module_item_id=6723096/"));
    assertEquals(expectedParams, route.getParamsHash());
    assertEquals("module_item_id=6723096/", route.getQueryString());
    // no slash at the end
    assertTrue(route.apply("https://mobiledev.instructure.com/courses/836357/quizzes/990775?module_item_id=6723096"));
    assertEquals(expectedParams, route.getParamsHash());
    assertEquals("module_item_id=6723096", route.getQueryString());
}
Also used : HashMap(java.util.HashMap) Route(com.instructure.interactions.router.Route) Test(org.junit.Test)

Example 10 with Route

use of com.instructure.interactions.router.Route in project instructure-android by instructure.

the class RouteTest method testRouteFragmentIdentifierParams.

// endregion
/*
     * Fragment Identifier
     */
@Test
public void testRouteFragmentIdentifierParams() {
    HashMap<String, String> expectedParams = new HashMap<>();
    expectedParams.put("course_id", "836357");
    expectedParams.put("quiz_id", "990775");
    Route route = new Route("/courses/:course_id/quizzes/:quiz_id");
    assertTrue(route.apply("https://mobiledev.instructure.com/courses/836357/quizzes/990775?module_item_id=6723096#Fragment Identifier"));
    assertEquals(expectedParams, route.getParamsHash());
    assertEquals("module_item_id=6723096", route.getQueryString());
    assertEquals("Fragment Identifier", route.getFragmentIdentifier());
}
Also used : HashMap(java.util.HashMap) Route(com.instructure.interactions.router.Route) Test(org.junit.Test)

Aggregations

Route (com.instructure.interactions.router.Route)12 Test (org.junit.Test)8 HashMap (java.util.HashMap)7 Bundle (android.os.Bundle)3 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)2 Rfc822Tokenizer (android.text.util.Rfc822Tokenizer)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 RecipientEditTextView (com.android.ex.chips.RecipientEditTextView)1 User (com.instructure.canvasapi2.models.User)1 AttachmentView (com.instructure.pandautils.views.AttachmentView)1 PeopleListRecyclerAdapter (com.instructure.teacher.adapters.PeopleListRecyclerAdapter)1 RecipientAdapter (com.instructure.teacher.adapters.RecipientAdapter)1 StudentContextFragment (com.instructure.teacher.adapters.StudentContextFragment)1 AdapterToFragmentCallback (com.instructure.teacher.interfaces.AdapterToFragmentCallback)1 AddMessageView (com.instructure.teacher.viewinterface.AddMessageView)1