@Test public void testScheduleJobSuccess_basicParametersOnly() { final Date dueDate = new Date(); final Long firstJobId = 1L; final Long secondJobId = 2L; when(executorServicesMock.scheduleRequest(eq(serverTemplateId), eq(JOB_TYPE), eq(dueDate), any())).thenReturn(firstJobId, secondJobId); presenter.createJob("firstJob", dueDate, JOB_TYPE, JOB_RETRIES, emptyList()); presenter.createJob("secondJob", dueDate, JOB_TYPE, JOB_RETRIES, null); verify(view).show(); verify(view, times(2)).cleanErrorMessages(); final ArgumentCaptor<NotificationEvent> captor = ArgumentCaptor.forClass(NotificationEvent.class); verify(notificationEvent, times(2)).fire(captor.capture()); assertEquals(2, captor.getAllValues().size()); assertEquals(NotificationEvent.NotificationType.DEFAULT, captor.getAllValues().get(0).getType()); assertEquals(NotificationEvent.NotificationType.DEFAULT, captor.getAllValues().get(1).getType()); assertEquals(Constants.INSTANCE.RequestScheduled(firstJobId), captor.getAllValues().get(0).getNotification()); assertEquals(Constants.INSTANCE.RequestScheduled(secondJobId), captor.getAllValues().get(1).getNotification()); verify(requestChangedEvent, times(2)).fire(any(RequestChangedEvent.class)); verify(view, times(2)).hide(); verifyNoMoreInteractions(view); }
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);  }