@Test public void testScheduleJobSuccess_withAdvancedParameters() { final String editMessage = "ClickToEdit"; final String paramKey = "paramKey"; final String paramValue = "paramValue"; final Date dueOnDate = new Date(); final SoftAssertions softly = new SoftAssertions(); doAnswer(invocation -> { softly.assertThat(invocation.getArguments()[0]).isEqualTo(serverTemplateId); softly.assertThat(invocation.getArguments()[1]).isEqualTo(JOB_TYPE); softly.assertThat(invocation.getArguments()[2]).isEqualTo(dueOnDate); final HashMap<String, String> ctxValues = (HashMap) invocation.getArguments()[3]; softly.assertThat(ctxValues).hasSize(3); softly.assertThat(ctxValues.get(RequestDataSetConstants.COLUMN_BUSINESSKEY).equals(JOB_NAME)); softly.assertThat(ctxValues.get(RequestDataSetConstants.COLUMN_RETRIES).equals(JOB_RETRIES)); softly.assertThat(ctxValues.get(paramKey).equals(paramValue)); return null; }).when(executorServicesMock).scheduleRequest(anyString(), anyString(), any(Date.class), any(Map.class)); presenter.createJob(JOB_NAME, dueOnDate, JOB_TYPE, JOB_RETRIES, Arrays.asList(new RequestParameterSummary(paramKey, paramValue), new RequestParameterSummary("paramKeyOnly", editMessage), new RequestParameterSummary(editMessage, "paramValueOnly"), new RequestParameterSummary(editMessage, editMessage))); softly.assertAll(); }
public void createJob(String jobName, Date dueDate, String jobType, String numberOfRetries, List<RequestParameterSummary> parameters) { if (validateForm(jobName, jobType, numberOfRetries)) { Map<String, String> jobCtxMap = new HashMap<String, String>(); if (parameters != null) { for (RequestParameterSummary param : parameters) { if (!(constants.ClickToEdit().equals(param.getKey()) || constants.ClickToEdit().equals(param.getValue()))) { jobCtxMap.put(param.getKey(), param.getValue()); } } } jobCtxMap.put(RequestDataSetConstants.COLUMN_RETRIES, numberOfRetries); jobCtxMap.put(RequestDataSetConstants.COLUMN_BUSINESSKEY, jobName); executorServices.call( (Long requestId) -> { displayNotification(constants.RequestScheduled(requestId)); requestCreatedEvent.fire(new RequestChangedEvent(requestId)); view.hide(); }, (Message message, Throwable throwable) -> { view.showBasicPane(); if (isInvalidCommandTypeError(throwable)) { view.showInvalidTypeErrorMessage(); } else { view.showInlineNotification(throwable.getCause().getMessage()); } return false; }).scheduleRequest(serverTemplateId, jobType, dueDate, jobCtxMap); } else { view.showBasicPane(); } }
NewJobPresenter { public void createJob(String jobName, Date dueDate, String jobType, String numberOfRetries, List<RequestParameterSummary> parameters) { if (validateForm(jobName, jobType, numberOfRetries)) { Map<String, String> jobCtxMap = new HashMap<String, String>(); if (parameters != null) { for (RequestParameterSummary param : parameters) { if (!(constants.ClickToEdit().equals(param.getKey()) || constants.ClickToEdit().equals(param.getValue()))) { jobCtxMap.put(param.getKey(), param.getValue()); } } } jobCtxMap.put(RequestDataSetConstants.COLUMN_RETRIES, numberOfRetries); jobCtxMap.put(RequestDataSetConstants.COLUMN_BUSINESSKEY, jobName); executorServices.call( (Long requestId) -> { displayNotification(constants.RequestScheduled(requestId)); requestCreatedEvent.fire(new RequestChangedEvent(requestId)); view.hide(); }, (Message message, Throwable throwable) -> { view.showBasicPane(); if (isInvalidCommandTypeError(throwable)) { view.showInvalidTypeErrorMessage(); } else { view.showInlineNotification(throwable.getCause().getMessage()); } return false; }).scheduleRequest(serverTemplateId, jobType, dueDate, jobCtxMap); } else { view.showBasicPane(); } } }
NewJobPresenter { public void createJob(String jobName, Date dueDate, String jobType, String numberOfRetries, List<RequestParameterSummary> parameters) { if (validateForm(jobName, jobType, numberOfRetries)) { Map<String, String> jobCtxMap = new HashMap<String, String>(); if (parameters != null) { for (RequestParameterSummary param : parameters) { if (!(constants.ClickToEdit().equals(param.getKey()) || constants.ClickToEdit().equals(param.getValue()))) { jobCtxMap.put(param.getKey(), param.getValue()); } } } jobCtxMap.put(RequestDataSetConstants.COLUMN_RETRIES, numberOfRetries); jobCtxMap.put(RequestDataSetConstants.COLUMN_BUSINESSKEY, jobName); executorServices.call( (Long requestId) -> { displayNotification(constants.RequestScheduled(requestId)); requestCreatedEvent.fire(new RequestChangedEvent(requestId)); view.hide(); }, (Message message, Throwable throwable) -> { view.showBasicPane(); if (isInvalidCommandTypeError(throwable)) { view.showInvalidTypeErrorMessage(); } else { view.showInlineNotification(throwable.getCause().getMessage()); } return false; }).scheduleRequest(serverTemplateId, jobType, dueDate, jobCtxMap); } else { view.showBasicPane(); } }  }
NewJobPresenter { public void createJob(String jobName, Date dueDate, String jobType, String numberOfRetries, List<RequestParameterSummary> parameters) { if (validateForm(jobName, jobType, numberOfRetries)) { Map<String, String> jobCtxMap = new HashMap<String, String>(); if (parameters != null) { for (RequestParameterSummary param : parameters) { if (!(constants.ClickToEdit().equals(param.getKey()) || constants.ClickToEdit().equals(param.getValue()))) { jobCtxMap.put(param.getKey(), param.getValue()); } } } jobCtxMap.put(RequestDataSetConstants.COLUMN_RETRIES, numberOfRetries); jobCtxMap.put(RequestDataSetConstants.COLUMN_BUSINESSKEY, jobName); executorServices.call( (Long requestId) -> { displayNotification(constants.RequestScheduled(requestId)); requestCreatedEvent.fire(new RequestChangedEvent(requestId)); view.hide(); }, (Message message, Throwable throwable) -> { view.showBasicPane(); if (isInvalidCommandTypeError(throwable)) { view.showInvalidTypeErrorMessage(); } else { view.showInlineNotification(throwable.getCause().getMessage()); } return false; }).scheduleRequest(serverTemplateId, jobType, dueDate, jobCtxMap); } else { view.showBasicPane(); } }  @PostConstruct void init(); void openNewJobDialog(String serverTemplateId); void createJob(String jobName,
                          Date dueDate,
                          String jobType,
                          String numberOfRetries,
                          List<RequestParameterSummary> parameters); @Inject void setNotification(final Event<NotificationEvent> notification); @Inject void setRequestChangedEvent(final Event<RequestChangedEvent> requestChangedEvent); @Inject void setExecutorService(final Caller<ExecutorService> executorService); }
NewJobPresenter { public void createJob(String jobName, Date dueDate, String jobType, String numberOfRetries, List<RequestParameterSummary> parameters) { if (validateForm(jobName, jobType, numberOfRetries)) { Map<String, String> jobCtxMap = new HashMap<String, String>(); if (parameters != null) { for (RequestParameterSummary param : parameters) { if (!(constants.ClickToEdit().equals(param.getKey()) || constants.ClickToEdit().equals(param.getValue()))) { jobCtxMap.put(param.getKey(), param.getValue()); } } } jobCtxMap.put(RequestDataSetConstants.COLUMN_RETRIES, numberOfRetries); jobCtxMap.put(RequestDataSetConstants.COLUMN_BUSINESSKEY, jobName); executorServices.call( (Long requestId) -> { displayNotification(constants.RequestScheduled(requestId)); requestCreatedEvent.fire(new RequestChangedEvent(requestId)); view.hide(); }, (Message message, Throwable throwable) -> { view.showBasicPane(); if (isInvalidCommandTypeError(throwable)) { view.showInvalidTypeErrorMessage(); } else { view.showInlineNotification(throwable.getCause().getMessage()); } return false; }).scheduleRequest(serverTemplateId, jobType, dueDate, jobCtxMap); } else { view.showBasicPane(); } }  @PostConstruct void init(); void openNewJobDialog(String serverTemplateId); void createJob(String jobName,
                          Date dueDate,
                          String jobType,
                          String numberOfRetries,
                          List<RequestParameterSummary> parameters); @Inject void setNotification(final Event<NotificationEvent> notification); @Inject void setRequestChangedEvent(final Event<RequestChangedEvent> requestChangedEvent); @Inject void setExecutorService(final Caller<ExecutorService> executorService);  }