@Before public void setUp() throws Exception { configuration = new RepositoryRestConfiguration(); handlerMapping = new RepositoryRestHandlerMapping(mappings, configuration); handlerMapping.setApplicationContext(CONTEXT); handlerMapping.afterPropertiesSet(); mockRequest = new MockHttpServletRequest(); listEntitiesMethod = RepositoryEntityController.class.getMethod( "listEntities", RootResourceInformation.class, Pageable.class, Sort.class); }
/** @see DATAREST-111 */ @Test public void looksUpRepositoryEntityControllerMethodCorrectly() throws Exception { when(mappings.exportsTopLevelResourceFor("people")).thenReturn(true); mockRequest = new MockHttpServletRequest("GET", "/people"); HandlerMethod method = handlerMapping.lookupHandlerMethod("/people", mockRequest); assertThat(method, is(notNullValue())); assertThat(method.getMethod(), is(listEntitiesMethod)); }
/** @see DATAREST-111 */ @Test public void returnsNullForUriNotMapped() throws Exception { assertThat(handlerMapping.lookupHandlerMethod("/foo", mockRequest), is(nullValue())); }