@Test public void should_convertStringToDate_when_stringRepresentsADateInUpdateTaskPayload() { UpdateTaskVariablePayload updateTaskVariablePayload = TaskPayloadBuilder.updateVariable().withVariable("date", "1970-01-01").build(); UpdateTaskVariablePayload handledDatePayload = taskVariablesPayloadValidator.handleUpdateTaskVariablePayload(updateTaskVariablePayload); assertThat(handledDatePayload.getValue()).isEqualTo(new Date(0)); }
public UpdateTaskVariablePayload handleUpdateTaskVariablePayload(UpdateTaskVariablePayload updateTaskVariablePayload) { checkNotValidCharactersInVariableName(updateTaskVariablePayload.getName(), "You cannot update a variable with not a valid name: "); Object value = updateTaskVariablePayload.getValue(); if (value instanceof String) { handleAsDate((String) value).ifPresent(updateTaskVariablePayload::setValue); } return updateTaskVariablePayload; }
TaskVariablesPayloadValidator { public UpdateTaskVariablePayload handleUpdateTaskVariablePayload(UpdateTaskVariablePayload updateTaskVariablePayload) { checkNotValidCharactersInVariableName(updateTaskVariablePayload.getName(), "You cannot update a variable with not a valid name: "); Object value = updateTaskVariablePayload.getValue(); if (value instanceof String) { handleAsDate((String) value).ifPresent(updateTaskVariablePayload::setValue); } return updateTaskVariablePayload; } }
TaskVariablesPayloadValidator { public UpdateTaskVariablePayload handleUpdateTaskVariablePayload(UpdateTaskVariablePayload updateTaskVariablePayload) { checkNotValidCharactersInVariableName(updateTaskVariablePayload.getName(), "You cannot update a variable with not a valid name: "); Object value = updateTaskVariablePayload.getValue(); if (value instanceof String) { handleAsDate((String) value).ifPresent(updateTaskVariablePayload::setValue); } return updateTaskVariablePayload; } TaskVariablesPayloadValidator(DateFormatterProvider dateFormatterProvider,
                                         VariableNameValidator variableNameValidator); }
TaskVariablesPayloadValidator { public UpdateTaskVariablePayload handleUpdateTaskVariablePayload(UpdateTaskVariablePayload updateTaskVariablePayload) { checkNotValidCharactersInVariableName(updateTaskVariablePayload.getName(), "You cannot update a variable with not a valid name: "); Object value = updateTaskVariablePayload.getValue(); if (value instanceof String) { handleAsDate((String) value).ifPresent(updateTaskVariablePayload::setValue); } return updateTaskVariablePayload; } TaskVariablesPayloadValidator(DateFormatterProvider dateFormatterProvider,
                                         VariableNameValidator variableNameValidator); CreateTaskVariablePayload handleCreateTaskVariablePayload(CreateTaskVariablePayload createTaskVariablePayload); UpdateTaskVariablePayload handleUpdateTaskVariablePayload(UpdateTaskVariablePayload updateTaskVariablePayload); Map<String, Object> handlePayloadVariables(Map<String, Object> variables); }
TaskVariablesPayloadValidator { public UpdateTaskVariablePayload handleUpdateTaskVariablePayload(UpdateTaskVariablePayload updateTaskVariablePayload) { checkNotValidCharactersInVariableName(updateTaskVariablePayload.getName(), "You cannot update a variable with not a valid name: "); Object value = updateTaskVariablePayload.getValue(); if (value instanceof String) { handleAsDate((String) value).ifPresent(updateTaskVariablePayload::setValue); } return updateTaskVariablePayload; } TaskVariablesPayloadValidator(DateFormatterProvider dateFormatterProvider,
                                         VariableNameValidator variableNameValidator); CreateTaskVariablePayload handleCreateTaskVariablePayload(CreateTaskVariablePayload createTaskVariablePayload); UpdateTaskVariablePayload handleUpdateTaskVariablePayload(UpdateTaskVariablePayload updateTaskVariablePayload); Map<String, Object> handlePayloadVariables(Map<String, Object> variables);  }