@Test void testStartScript() throws IOException { Map<String, Object> parameters = newHashMap(); parameters.put("arg1", "value1"); HttpServletResponse response = mock(HttpServletResponse.class); when(jobsController.createJobExecutionViewHref("/api/v2/sys_job_test/ID", 1000)) .thenReturn("redirect:url"); controller.startScript("test", parameters, response); verify(jobExecutor).submit(scriptJobExecution); verify(scriptJobExecution).setName("test"); verify(scriptJobExecution).setParameters(gson.toJson(parameters)); verify(response).sendRedirect("redirect:url"); }
@SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/start") public void startScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters, HttpServletResponse response) throws IOException { String scriptJobExecutionHref = submitScript(scriptName, parameters).getBody(); response.sendRedirect(jobsController.createJobExecutionViewHref(scriptJobExecutionHref, 1000)); }
ScriptRunnerController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/start") public void startScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters, HttpServletResponse response) throws IOException { String scriptJobExecutionHref = submitScript(scriptName, parameters).getBody(); response.sendRedirect(jobsController.createJobExecutionViewHref(scriptJobExecutionHref, 1000)); } }
ScriptRunnerController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/start") public void startScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters, HttpServletResponse response) throws IOException { String scriptJobExecutionHref = submitScript(scriptName, parameters).getBody(); response.sendRedirect(jobsController.createJobExecutionViewHref(scriptJobExecutionHref, 1000)); } ScriptRunnerController(
      ScriptJobExecutionFactory scriptJobExecutionFactory,
      JobExecutor jobExecutor,
      SavedScriptRunner savedScriptRunner,
      Gson gson,
      JobsController jobsController); }
ScriptRunnerController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/start") public void startScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters, HttpServletResponse response) throws IOException { String scriptJobExecutionHref = submitScript(scriptName, parameters).getBody(); response.sendRedirect(jobsController.createJobExecutionViewHref(scriptJobExecutionHref, 1000)); } ScriptRunnerController(
      ScriptJobExecutionFactory scriptJobExecutionFactory,
      JobExecutor jobExecutor,
      SavedScriptRunner savedScriptRunner,
      Gson gson,
      JobsController jobsController); @SuppressWarnings("java:S3752") // backwards compatability: multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/start") void startScript(
      @PathVariable("name") String scriptName,
      @RequestParam Map<String, Object> parameters,
      HttpServletResponse response); @SuppressWarnings("java:S3752") // backwards compatability: multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/submit", produces = TEXT_PLAIN_VALUE) ResponseEntity<String> submitScript(
      @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters); @SuppressWarnings("java:S3752") // backwards compatability: multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/run") void runScript(
      @PathVariable("name") String scriptName,
      @RequestParam Map<String, Object> parameters,
      HttpServletResponse response); @ExceptionHandler(UnknownScriptException.class) void handleUnknownScriptException(UnknownScriptException e, HttpServletResponse response); @ExceptionHandler(ScriptException.class) void handleGenerateScriptException(ScriptException e, HttpServletResponse response); }
ScriptRunnerController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/start") public void startScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters, HttpServletResponse response) throws IOException { String scriptJobExecutionHref = submitScript(scriptName, parameters).getBody(); response.sendRedirect(jobsController.createJobExecutionViewHref(scriptJobExecutionHref, 1000)); } ScriptRunnerController(
      ScriptJobExecutionFactory scriptJobExecutionFactory,
      JobExecutor jobExecutor,
      SavedScriptRunner savedScriptRunner,
      Gson gson,
      JobsController jobsController); @SuppressWarnings("java:S3752") // backwards compatability: multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/start") void startScript(
      @PathVariable("name") String scriptName,
      @RequestParam Map<String, Object> parameters,
      HttpServletResponse response); @SuppressWarnings("java:S3752") // backwards compatability: multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/submit", produces = TEXT_PLAIN_VALUE) ResponseEntity<String> submitScript(
      @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters); @SuppressWarnings("java:S3752") // backwards compatability: multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/run") void runScript(
      @PathVariable("name") String scriptName,
      @RequestParam Map<String, Object> parameters,
      HttpServletResponse response); @ExceptionHandler(UnknownScriptException.class) void handleUnknownScriptException(UnknownScriptException e, HttpServletResponse response); @ExceptionHandler(ScriptException.class) void handleGenerateScriptException(ScriptException e, HttpServletResponse response);  }