@Test public void should_doNothing_when_stringIsNotADateInUpdateTaskPayload() { UpdateTaskVariablePayload updateTaskVariablePayload = TaskPayloadBuilder .updateVariable() .withVariable("notADate", "this is not a date") .build(); UpdateTaskVariablePayload handledDatePayload = taskVariablesPayloadValidator.handleUpdateTaskVariablePayload(updateTaskVariablePayload); assertThat(handledDatePayload.getValue()).isEqualTo("this is not a date"); }
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);  }