RequestConfigServiceImpl implements InitializingBean { public RequestConfig findConfiguration(String path) { for(RequestConfig config : configSet) { if(config.matches(path)) { return config; } } throw new RuntimeException("No mapping found for path: " + path); }  RequestConfig findConfiguration(String path); @Override void afterPropertiesSet();  }
@Test public void testFindConfiguration() throws Exception { RequestConfig configuration = requestConfigService.findConfiguration("/rest/api/todo"); assertNotNull("Configuration for todo REST must not be null.", configuration); }
@Test public void testFindConfigurationSubpath() throws Exception { RequestConfig configuration = requestConfigService.findConfiguration("/rest/api/todo/123/user"); assertNotNull("Configuration for todo REST must not be null.", configuration); }
@Test public void testFindConfigurationForTestAPI() throws Exception { RequestConfig configuration = requestConfigService.findConfiguration("/rest/api/test"); assertNotNull("Configuration for test REST must not be null.", configuration); }
@Test(expected = RuntimeException.class) public void testFindConfigurationMissing() throws Exception { requestConfigService.findConfiguration("/doesnotexist"); }