@Test void canGetFile() throws Exception { final String id = UUID.randomUUID().toString(); final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); Mockito .when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)) .thenReturn("/file/" + id + "/output/genie/log.out"); Mockito .when(request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE)) .thenReturn("/file/{id}/**"); final String encodedId = URLEncoder.encode(id, "UTF-8"); final String expectedPath = "/api/v3/jobs/" + encodedId + "/output/genie/log.out"; Assertions.assertThat(this.controller.getFile(id, request)).isEqualTo("forward:" + expectedPath); }
@GetMapping(value = "/file/{id}/**") public String getFile( @PathVariable("id") final String id, final HttpServletRequest request ) throws UnsupportedEncodingException { final String encodedId = URLEncoder.encode(id, "UTF-8"); final String path = "/api/v3/jobs/" + encodedId + "/" + ControllerUtils.getRemainingPath(request); return "forward:" + path; }
UIController { @GetMapping(value = "/file/{id}/**") public String getFile( @PathVariable("id") final String id, final HttpServletRequest request ) throws UnsupportedEncodingException { final String encodedId = URLEncoder.encode(id, "UTF-8"); final String path = "/api/v3/jobs/" + encodedId + "/" + ControllerUtils.getRemainingPath(request); return "forward:" + path; } }
UIController { @GetMapping(value = "/file/{id}/**") public String getFile( @PathVariable("id") final String id, final HttpServletRequest request ) throws UnsupportedEncodingException { final String encodedId = URLEncoder.encode(id, "UTF-8"); final String path = "/api/v3/jobs/" + encodedId + "/" + ControllerUtils.getRemainingPath(request); return "forward:" + path; }  }
UIController { @GetMapping(value = "/file/{id}/**") public String getFile( @PathVariable("id") final String id, final HttpServletRequest request ) throws UnsupportedEncodingException { final String encodedId = URLEncoder.encode(id, "UTF-8"); final String path = "/api/v3/jobs/" + encodedId + "/" + ControllerUtils.getRemainingPath(request); return "forward:" + path; }  @GetMapping( value = { "/", "/applications/**", "/clusters/**", "/commands/**", "/jobs/**", "/output/**" } ) String getIndex(); @GetMapping(value = "/file/{id}/**") String getFile(
        @PathVariable("id") final String id,
        final HttpServletRequest request
    ); }
UIController { @GetMapping(value = "/file/{id}/**") public String getFile( @PathVariable("id") final String id, final HttpServletRequest request ) throws UnsupportedEncodingException { final String encodedId = URLEncoder.encode(id, "UTF-8"); final String path = "/api/v3/jobs/" + encodedId + "/" + ControllerUtils.getRemainingPath(request); return "forward:" + path; }  @GetMapping( value = { "/", "/applications/**", "/clusters/**", "/commands/**", "/jobs/**", "/output/**" } ) String getIndex(); @GetMapping(value = "/file/{id}/**") String getFile(
        @PathVariable("id") final String id,
        final HttpServletRequest request
    );  }