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