@Test
public void returnsResponseWithStatus_UNSUPPORTED_MEDIA_TYPE_WhenSubResourceMethodDoesNotSupportContentTypeOfRequest() throws Exception {

    when(applicationContext.getPathSegments(false)).thenReturn(createPathSegments("a", "b", "c", "d;x=y"));
    when(request.getMediaType()).thenReturn(APPLICATION_JSON_TYPE);
    Resource resource = new Resource();
    SubResourceMethodDescriptor subResourceMethod =
            mockSubResourceMethod(Resource.class.getMethod("echo", String.class), "c/d", "POST", newArrayList(TEXT_PLAIN_TYPE), newArrayList(WILDCARD_TYPE));
    ObjectFactory resourceFactory = mockResourceFactory(resource, newArrayList(), newArrayList(subResourceMethod), newArrayList());
    matchRequestPath("c/d");
    when(resources.getMatchedResource(eq("/a/b/c/d"), anyList())).thenReturn(resourceFactory);
    requestDispatcher.dispatch(request, response);
    ArgumentCaptor<Response> argumentCaptor = ArgumentCaptor.forClass(Response.class);
    verify(response, atLeastOnce()).setResponse(argumentCaptor.capture());
    assertEquals(UNSUPPORTED_MEDIA_TYPE, argumentCaptor.getValue().getStatusInfo());
}