DatastoreStorage implements Closeable { Optional<WorkflowWithState> workflowWithState(WorkflowId workflowId) throws IOException { final Optional<Entity> workflowEntity = getWorkflowOpt(datastore, datastore::newKeyFactory, workflowId); if (workflowEntity.isEmpty()) { return Optional.empty(); } var workflow = parseWorkflowJson(workflowEntity.orElseThrow(), workflowId); var workflowState = workflowState(workflowEntity); return Optional.of(WorkflowWithState.create(workflow, workflowState)); } DatastoreStorage(CheckedDatastore datastore); @VisibleForTesting  DatastoreStorage(CheckedDatastore datastore,
                   Function<CheckedDatastoreTransaction, DatastoreStorageTransaction> storageTransactionFactory,
                   ExecutorService executor, Logger log); @Override void close(); void updateNextNaturalTrigger(WorkflowId workflowId, TriggerInstantSpec triggerSpec); Map<WorkflowId, Workflow> workflows(); Map<WorkflowId, Workflow> workflows(Set<WorkflowId> workflowIds); List<Workflow> workflows(String componentId); T runInTransactionWithRetries(TransactionFunction<T, E> f);  }
@Test public void shouldReturnEmptyWorkflowWithState() throws Exception { var retrieved = storage.workflowWithState(WORKFLOW.id()); assertThat(retrieved.isEmpty(), is(true)); }