@Test
public void findsSubResourceWithRequestedHttpMethodWhenPathMatchesToMoreThanOneSubResourcesPaths() throws Exception {

    when(applicationContext.getPathSegments(false)).thenReturn(createPathSegments("a", "b"));
    when(request.getMethod()).thenReturn("DELETE");
    when(request.getAcceptMediaTypeList()).thenReturn(newArrayList(new AcceptMediaType(TEXT_PLAIN_TYPE)));
    Resource resource = new Resource();
    SubResourceMethodDescriptor subResourceMethodOne =
            mockSubResourceMethod(Resource.class.getMethod("echo", String.class),"(.*)", "GET", newArrayList(WILDCARD_TYPE), newArrayList(TEXT_PLAIN_TYPE));
    SubResourceMethodDescriptor subResourceMethodTwo =
            mockSubResourceMethod(Resource.class.getMethod("echo", String.class), ".*", "DELETE", newArrayList(WILDCARD_TYPE), newArrayList(TEXT_PLAIN_TYPE));
    ObjectFactory resourceFactory = mockResourceFactory(resource, newArrayList(), newArrayList(subResourceMethodOne, subResourceMethodTwo), newArrayList());
    matchRequestPath("b");
    when(resources.getMatchedResource(eq("/a/b"), anyList())).thenReturn(resourceFactory);
    when(methodInvoker.invokeMethod(same(resource), same(subResourceMethodOne), same(applicationContext))).thenReturn("get");
    when(methodInvoker.invokeMethod(same(resource), same(subResourceMethodTwo), same(applicationContext))).thenReturn("delete");
    requestDispatcher.dispatch(request, response);
    ArgumentCaptor<Response> argumentCaptor = ArgumentCaptor.forClass(Response.class);
    verify(response, atLeastOnce()).setResponse(argumentCaptor.capture());
    assertEquals(OK, argumentCaptor.getValue().getStatusInfo());
    assertEquals("delete", argumentCaptor.getValue().getEntity());
}