PathExtractor { String path(RequestContext context) { HttpServletRequest request = context.getRequest(); StringBuilder builder = new StringBuilder(); builder.append(request.getContextPath()).append(request.getServletPath()); if (request.getPathInfo() != null) { builder.append(request.getPathInfo()); } if (context.getRequestQueryParams() != null) { appendQueryParams(context, builder); } return builder.toString(); }    }
@Test public void extractsPathWithQueryStringAndPathInfo() { when(servletRequest.getPathInfo()).thenReturn("/id"); when(requestContext.getRequestQueryParams()).thenReturn(queryParams); String path = extractor.path(requestContext); assertThat(path).isEqualTo("/root/path/to/resource/id?n=3&n=5"); }