@Test
public void sortsSubResourceMethodsByUriPatterAndConsumesAndProducesTypes() {

    ResourceDescriptor resource = new AbstractResourceDescriptor(ResourceForTestSortingOfSubResourceMethods.class);
    Map<UriPattern, Map<String, List<SubResourceMethodDescriptor>>> subResourceMethods = resource.getSubResourceMethods();
    assertEquals(newArrayList("/b/c/d", "/b/c", "/b/{c}", "/b"), subResourceMethods.keySet().stream().map(UriPattern::getTemplate).collect(toList()));
    assertEquals(1, subResourceMethods.get(new UriPattern("/b/c/d")).get("GET").size());
    assertEquals(1, subResourceMethods.get(new UriPattern("/b/c")).get("GET").size());
    assertEquals(1, subResourceMethods.get(new UriPattern("/b/{c}")).get("GET").size());
    assertEquals(3, subResourceMethods.get(new UriPattern("/b")).get("GET").size());
    List<String> methodNames = subResourceMethods.get(new UriPattern("/b")).get("GET").stream().map(subResourceMethod -> subResourceMethod.getMethod().getName()).collect(toList());
    assertEquals(newArrayList("m2", "m5", "m0"), methodNames);
}