@Test void canGetRemainingPath() { final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); Mockito.when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).thenReturn(null); Assertions.assertThat(ControllerUtils.getRemainingPath(request)).isEqualTo(""); Mockito .when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)) .thenReturn("/api/v3/jobs/1234/output/genie/log.out"); Mockito .when(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)) .thenReturn("/api/v3/jobs/{id}/output/**"); Assertions.assertThat(ControllerUtils.getRemainingPath(request)).isEqualTo("genie/log.out"); Mockito .when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)) .thenReturn("/api/v3/jobs/1234/output"); Mockito .when(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)) .thenReturn("/api/v3/jobs/{id}/output"); Assertions.assertThat(ControllerUtils.getRemainingPath(request)).isEqualTo(""); Mockito .when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)) .thenReturn("/api/v3/jobs/1234/output/"); Mockito .when(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)) .thenReturn("/api/v3/jobs/{id}/output/"); Assertions.assertThat(ControllerUtils.getRemainingPath(request)).isEqualTo(""); Mockito .when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)) .thenReturn("/api/v3/jobs/1234/output/stdout"); Mockito .when(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)) .thenReturn("/api/v3/jobs/{id}/output/**"); Assertions.assertThat(ControllerUtils.getRemainingPath(request)).isEqualTo("stdout"); }
public static String getRemainingPath(final HttpServletRequest request) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (path != null) { final String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); log.debug("bestMatchPattern = {}", bestMatchPattern); path = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); } path = path == null ? EMPTY_STRING : path; log.debug("Remaining path = {}", path); return path; }
ControllerUtils { public static String getRemainingPath(final HttpServletRequest request) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (path != null) { final String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); log.debug("bestMatchPattern = {}", bestMatchPattern); path = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); } path = path == null ? EMPTY_STRING : path; log.debug("Remaining path = {}", path); return path; } }
ControllerUtils { public static String getRemainingPath(final HttpServletRequest request) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (path != null) { final String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); log.debug("bestMatchPattern = {}", bestMatchPattern); path = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); } path = path == null ? EMPTY_STRING : path; log.debug("Remaining path = {}", path); return path; } private  ControllerUtils(); }
ControllerUtils { public static String getRemainingPath(final HttpServletRequest request) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (path != null) { final String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); log.debug("bestMatchPattern = {}", bestMatchPattern); path = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); } path = path == null ? EMPTY_STRING : path; log.debug("Remaining path = {}", path); return path; } private  ControllerUtils(); static String getRemainingPath(final HttpServletRequest request); }
ControllerUtils { public static String getRemainingPath(final HttpServletRequest request) { String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); if (path != null) { final String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); log.debug("bestMatchPattern = {}", bestMatchPattern); path = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); } path = path == null ? EMPTY_STRING : path; log.debug("Remaining path = {}", path); return path; } private  ControllerUtils(); static String getRemainingPath(final HttpServletRequest request);  }