@Test public void testInvalidParameters() throws TaskException { parameters.setVersion(PdfVersion.VERSION_1_4); parameters.setCompress(true); victim.execute(parameters); verify(task, never()).before(eq(parameters), any()); verify(task, never()).after(); verify(task, never()).execute(parameters); }
@Override public void execute(TaskParameters parameters) { TaskExecutionContext executionContext = null; LOG.trace("Starting execution for {}", parameters); try { validateIfRequired(parameters); executionContext = new TaskExecutionContext(context.getTask(parameters), parameters.isLenient()); LOG.info("Starting task ({}) execution.", executionContext.task()); preExecution(executionContext); actualExecution(parameters, executionContext); postExecution(executionContext); } catch (InvalidTaskParametersException i) { LOG.error("Task execution failed due to invalid parameters: " + String.join(". ", i.getReasons()), i); executionFailed(i, executionContext); } catch (TaskException e) { LOG.error(String.format("Task (%s) execution failed.", ofNullable(executionContext).map(c -> c.task().toString()).orElse("")), e); executionFailed(e, executionContext); } catch (RuntimeException e) { executionFailed(e, executionContext); throw e; } }
DefaultTaskExecutionService implements TaskExecutionService { @Override public void execute(TaskParameters parameters) { TaskExecutionContext executionContext = null; LOG.trace("Starting execution for {}", parameters); try { validateIfRequired(parameters); executionContext = new TaskExecutionContext(context.getTask(parameters), parameters.isLenient()); LOG.info("Starting task ({}) execution.", executionContext.task()); preExecution(executionContext); actualExecution(parameters, executionContext); postExecution(executionContext); } catch (InvalidTaskParametersException i) { LOG.error("Task execution failed due to invalid parameters: " + String.join(". ", i.getReasons()), i); executionFailed(i, executionContext); } catch (TaskException e) { LOG.error(String.format("Task (%s) execution failed.", ofNullable(executionContext).map(c -> c.task().toString()).orElse("")), e); executionFailed(e, executionContext); } catch (RuntimeException e) { executionFailed(e, executionContext); throw e; } } }
DefaultTaskExecutionService implements TaskExecutionService { @Override public void execute(TaskParameters parameters) { TaskExecutionContext executionContext = null; LOG.trace("Starting execution for {}", parameters); try { validateIfRequired(parameters); executionContext = new TaskExecutionContext(context.getTask(parameters), parameters.isLenient()); LOG.info("Starting task ({}) execution.", executionContext.task()); preExecution(executionContext); actualExecution(parameters, executionContext); postExecution(executionContext); } catch (InvalidTaskParametersException i) { LOG.error("Task execution failed due to invalid parameters: " + String.join(". ", i.getReasons()), i); executionFailed(i, executionContext); } catch (TaskException e) { LOG.error(String.format("Task (%s) execution failed.", ofNullable(executionContext).map(c -> c.task().toString()).orElse("")), e); executionFailed(e, executionContext); } catch (RuntimeException e) { executionFailed(e, executionContext); throw e; } }  }
DefaultTaskExecutionService implements TaskExecutionService { @Override public void execute(TaskParameters parameters) { TaskExecutionContext executionContext = null; LOG.trace("Starting execution for {}", parameters); try { validateIfRequired(parameters); executionContext = new TaskExecutionContext(context.getTask(parameters), parameters.isLenient()); LOG.info("Starting task ({}) execution.", executionContext.task()); preExecution(executionContext); actualExecution(parameters, executionContext); postExecution(executionContext); } catch (InvalidTaskParametersException i) { LOG.error("Task execution failed due to invalid parameters: " + String.join(". ", i.getReasons()), i); executionFailed(i, executionContext); } catch (TaskException e) { LOG.error(String.format("Task (%s) execution failed.", ofNullable(executionContext).map(c -> c.task().toString()).orElse("")), e); executionFailed(e, executionContext); } catch (RuntimeException e) { executionFailed(e, executionContext); throw e; } }  @Override void execute(TaskParameters parameters); void validate(TaskParameters parameters); }
DefaultTaskExecutionService implements TaskExecutionService { @Override public void execute(TaskParameters parameters) { TaskExecutionContext executionContext = null; LOG.trace("Starting execution for {}", parameters); try { validateIfRequired(parameters); executionContext = new TaskExecutionContext(context.getTask(parameters), parameters.isLenient()); LOG.info("Starting task ({}) execution.", executionContext.task()); preExecution(executionContext); actualExecution(parameters, executionContext); postExecution(executionContext); } catch (InvalidTaskParametersException i) { LOG.error("Task execution failed due to invalid parameters: " + String.join(". ", i.getReasons()), i); executionFailed(i, executionContext); } catch (TaskException e) { LOG.error(String.format("Task (%s) execution failed.", ofNullable(executionContext).map(c -> c.task().toString()).orElse("")), e); executionFailed(e, executionContext); } catch (RuntimeException e) { executionFailed(e, executionContext); throw e; } }  @Override void execute(TaskParameters parameters); void validate(TaskParameters parameters);  }