Search in sources :

Example 6 with PortalRequest

use of org.apereo.portal.soffit.model.v1_0.PortalRequest in project uPortal by Jasig.

the class ModelAttributeServiceTest method testPrepareMethodParameters.

@Test
public void testPrepareMethodParameters() {
    final ModelAttributeService modelAttributeService = new ModelAttributeService();
    final Class[] parameterClasses = new Class[] { HttpServletRequest.class, PortalRequest.class, Bearer.class };
    final Method method;
    try {
        method = getClass().getMethod("soffitModelAttributeMethod", parameterClasses);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
    // Object Model
    final HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
    final HttpServletResponse res = Mockito.mock(HttpServletResponse.class);
    final PortalRequest portalRequest = Mockito.mock(PortalRequest.class);
    final Bearer bearer = Mockito.mock(Bearer.class);
    final Preferences preferences = Mockito.mock(Preferences.class);
    final Definition definition = Mockito.mock(Definition.class);
    final Object[] parameters = modelAttributeService.prepareMethodParameters(method, req, res, portalRequest, bearer, preferences, definition);
    assertEquals("parameterClasses and parameters arrays must be the same length", parameterClasses.length, parameters.length);
    for (int i = 0; i < parameters.length; i++) {
        assertTrue("Mismatched parameter type", parameterClasses[i].isInstance(parameters[i]));
    }
}
Also used : Definition(org.apereo.portal.soffit.model.v1_0.Definition) HttpServletResponse(javax.servlet.http.HttpServletResponse) Method(java.lang.reflect.Method) PortalRequest(org.apereo.portal.soffit.model.v1_0.PortalRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Preferences(org.apereo.portal.soffit.model.v1_0.Preferences) Bearer(org.apereo.portal.soffit.model.v1_0.Bearer) Test(org.junit.Test)

Aggregations

PortalRequest (org.apereo.portal.soffit.model.v1_0.PortalRequest)6 Bearer (org.apereo.portal.soffit.model.v1_0.Bearer)3 Definition (org.apereo.portal.soffit.model.v1_0.Definition)3 Preferences (org.apereo.portal.soffit.model.v1_0.Preferences)3 Claims (io.jsonwebtoken.Claims)2 Method (java.lang.reflect.Method)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Test (org.junit.Test)2 List (java.util.List)1 Map (java.util.Map)1 Header (org.apache.http.Header)1 BasicHeader (org.apache.http.message.BasicHeader)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1