DatastoreStorageTransaction implements StorageTransaction { @Override public WorkflowId storeWorkflowWithNextNaturalTrigger(Workflow workflow, TriggerInstantSpec triggerSpec) throws IOException { var existing = getWorkflowOpt(tx, workflow.id()); return storeWorkflow(workflow, WorkflowState.ofTriggerSpec(triggerSpec), existing); } DatastoreStorageTransaction(CheckedDatastoreTransaction transaction); @Override void updateCounter(ShardedCounter shardedCounter, String resource, int delta); @Override Optional<Shard> shard(String counterId, int shardIndex); @Override void store(Shard shard); @Override void updateLimitForCounter(String counterId, long limit); @Override void store(Resource resource); @Override WorkflowId deleteWorkflow(WorkflowId workflowId); @Override WorkflowId store(Workflow workflow); @Override WorkflowId storeWorkflowWithNextNaturalTrigger(Workflow workflow, TriggerInstantSpec triggerSpec); @Override Optional<Workflow> workflow(WorkflowId workflowId); @Override WorkflowId updateNextNaturalTrigger(WorkflowId workflowId, TriggerInstantSpec triggerSpec); @Override WorkflowId patchState(WorkflowId workflowId, WorkflowState state); @Override Optional<RunState> readActiveState(WorkflowInstance instance); @Override WorkflowInstance writeActiveState(WorkflowInstance instance, RunState state); @Override WorkflowInstance updateActiveState(WorkflowInstance instance, RunState state); @Override WorkflowInstance deleteActiveState(WorkflowInstance instance); @Override Backfill store(Backfill backfill); @Override Optional<Backfill> backfill(String id);  }
@Test public void shouldStoreWorkflowWithNextNaturalTrigger() throws Exception { var instant = Instant.parse("2016-03-14T14:00:00Z"); var offset = instant.plus(1, ChronoUnit.DAYS); var spec = TriggerInstantSpec.create(instant, offset); var workflow = Workflow.create("test", FULL_WORKFLOW_CONFIGURATION); storage.runInTransactionWithRetries(tx -> { tx.storeWorkflowWithNextNaturalTrigger(workflow, spec); return null; }); var workflows = storage.workflowsWithNextNaturalTrigger(); assertThat(workflows.values().size(), is(1)); assertThat(workflows, hasEntry(workflow, spec)); }