@Test void testSubmitScript() { Map<String, Object> parameters = newHashMap(); parameters.put("arg1", "value1"); ResponseEntity responseEntity = controller.submitScript("test", parameters); assertEquals(200, responseEntity.getStatusCodeValue()); assertEquals("/api/v2/sys_job_test/ID", responseEntity.getBody()); verify(jobExecutor).submit(scriptJobExecution); verify(scriptJobExecution).setName("test"); verify(scriptJobExecution).setParameters(gson.toJson(parameters)); }
@SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/submit", produces = TEXT_PLAIN_VALUE) public ResponseEntity<String> submitScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters) { ScriptJobExecution scriptJobExecution = scriptJobExecutionFactory.create(); scriptJobExecution.setName(scriptName); scriptJobExecution.setParameters(gson.toJson(parameters)); jobExecutor.submit(scriptJobExecution); return ok(JobExecutionUriUtils.getUriPath(scriptJobExecution)); }
ScriptRunnerController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/submit", produces = TEXT_PLAIN_VALUE) public ResponseEntity<String> submitScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters) { ScriptJobExecution scriptJobExecution = scriptJobExecutionFactory.create(); scriptJobExecution.setName(scriptName); scriptJobExecution.setParameters(gson.toJson(parameters)); jobExecutor.submit(scriptJobExecution); return ok(JobExecutionUriUtils.getUriPath(scriptJobExecution)); } }
ScriptRunnerController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/submit", produces = TEXT_PLAIN_VALUE) public ResponseEntity<String> submitScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters) { ScriptJobExecution scriptJobExecution = scriptJobExecutionFactory.create(); scriptJobExecution.setName(scriptName); scriptJobExecution.setParameters(gson.toJson(parameters)); jobExecutor.submit(scriptJobExecution); return ok(JobExecutionUriUtils.getUriPath(scriptJobExecution)); } ScriptRunnerController(
      ScriptJobExecutionFactory scriptJobExecutionFactory,
      JobExecutor jobExecutor,
      SavedScriptRunner savedScriptRunner,
      Gson gson,
      JobsController jobsController); }
ScriptRunnerController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/scripts/{name}/submit", produces = TEXT_PLAIN_VALUE) public ResponseEntity<String> submitScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters) { ScriptJobExecution scriptJobExecution = scriptJobExecutionFactory.create(); scriptJobExecution.setName(scriptName); scriptJobExecution.setParameters(gson.toJson(parameters)); jobExecutor.submit(scriptJobExecution); return ok(JobExecutionUriUtils.getUriPath(scriptJobExecution)); } 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}/submit", produces = TEXT_PLAIN_VALUE) public ResponseEntity<String> submitScript( @PathVariable("name") String scriptName, @RequestParam Map<String, Object> parameters) { ScriptJobExecution scriptJobExecution = scriptJobExecutionFactory.create(); scriptJobExecution.setName(scriptName); scriptJobExecution.setParameters(gson.toJson(parameters)); jobExecutor.submit(scriptJobExecution); return ok(JobExecutionUriUtils.getUriPath(scriptJobExecution)); } 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);  }