### Question:
ResourceService implements IResourceService { @Override public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest) { return resourceConfigAttributes.keySet().stream() .filter(requestMatcher -> requestMatcher.matches(authRequest)) .map(requestMatcher -> resourceConfigAttributes.get(requestMatcher)) .peek(urlConfigAttribute -> log.debug("url在资源池中配置：{}", urlConfigAttribute.getAttribute())) .findFirst() .orElse(new SecurityConfig("NONEXISTENT_URL")); }  @Override synchronized void saveResource(Resource resource); @Override synchronized void removeResource(Resource resource); @Override synchronized void loadResource(); @Override ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest); @Override @Cached(name = "resource4user::", key = "#username", cacheType = CacheType.LOCAL) Set<Resource> queryByUsername(String username);  }### Answer:
@Test @Ignore public void testGetConfigAttributesByUrl_假如存在如上资源信息_当请求不存在method的资源时_那么返回NONEXISTENT_URL() { ConfigAttribute attributesByUrl = resourceService .findConfigAttributesByUrl(new HttpServletRequestAuthWrapper(new MockHttpServletRequest(), "/users/1/order", "POST")); Assert.assertEquals("NONEXISTENT_URL", attributesByUrl.getAttribute()); }
@Test @Ignore public void testGetConfigAttributesByUrl_假如存在如上资源信息_当请求url存在参数时_那么返回匹配的资源信息() { ConfigAttribute attributesByUrl = resourceService .findConfigAttributesByUrl(new HttpServletRequestAuthWrapper(new MockHttpServletRequest(), "/users/1/order", "GET")); Assert.assertEquals("NONEXISTENT_URL", attributesByUrl.getAttribute()); }
@Test @Ignore public void testGetConfigAttributesByUrl_假如存在如上资源信息_当请求存在的资源时_那么返回url和method都匹配的资源信息() { ConfigAttribute attributesByUrl = resourceService .findConfigAttributesByUrl(new HttpServletRequestAuthWrapper(new MockHttpServletRequest(), "/users", "POST")); Assert.assertEquals("user_manager:btn_add", attributesByUrl.getAttribute()); }