@Test public void insertWorkflowInstanceWorks() { WorkflowInstance i = constructWorkflowInstanceBuilder().setStatus(created).setExternalId("123").setState(null).build(); when(workflowInstancePreProcessor.process(i)).thenReturn(i); when(workflowInstanceDao.insertWorkflowInstance(stored.capture())).thenReturn(42L); assertThat(service.insertWorkflowInstance(i), is(42L)); assertThat(stored.getValue().externalId, is("123")); assertThat(stored.getValue().status, is(created)); }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "getInitialState().toString() has no cast") public long insertWorkflowInstance(WorkflowInstance instance) { Assert.notNull(workflowInstancePreProcessor, "workflowInstancePreProcessor can not be null"); WorkflowInstance processedInstance = workflowInstancePreProcessor.process(instance); long id = workflowInstanceDao.insertWorkflowInstance(processedInstance); if (id == -1 && !isEmpty(instance.externalId)) { QueryWorkflowInstances query = new QueryWorkflowInstances.Builder().addTypes(instance.type).setExternalId(instance.externalId).build(); id = workflowInstanceDao.queryWorkflowInstances(query).get(0).id; } return id; }
WorkflowInstanceService { @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "getInitialState().toString() has no cast") public long insertWorkflowInstance(WorkflowInstance instance) { Assert.notNull(workflowInstancePreProcessor, "workflowInstancePreProcessor can not be null"); WorkflowInstance processedInstance = workflowInstancePreProcessor.process(instance); long id = workflowInstanceDao.insertWorkflowInstance(processedInstance); if (id == -1 && !isEmpty(instance.externalId)) { QueryWorkflowInstances query = new QueryWorkflowInstances.Builder().addTypes(instance.type).setExternalId(instance.externalId).build(); id = workflowInstanceDao.queryWorkflowInstances(query).get(0).id; } return id; } }
WorkflowInstanceService { @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "getInitialState().toString() has no cast") public long insertWorkflowInstance(WorkflowInstance instance) { Assert.notNull(workflowInstancePreProcessor, "workflowInstancePreProcessor can not be null"); WorkflowInstance processedInstance = workflowInstancePreProcessor.process(instance); long id = workflowInstanceDao.insertWorkflowInstance(processedInstance); if (id == -1 && !isEmpty(instance.externalId)) { QueryWorkflowInstances query = new QueryWorkflowInstances.Builder().addTypes(instance.type).setExternalId(instance.externalId).build(); id = workflowInstanceDao.queryWorkflowInstances(query).get(0).id; } return id; } @Inject  WorkflowInstanceService(WorkflowInstanceDao workflowInstanceDao, WorkflowDefinitionService workflowDefinitionService,
      WorkflowInstancePreProcessor workflowInstancePreProcessor); }
WorkflowInstanceService { @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "getInitialState().toString() has no cast") public long insertWorkflowInstance(WorkflowInstance instance) { Assert.notNull(workflowInstancePreProcessor, "workflowInstancePreProcessor can not be null"); WorkflowInstance processedInstance = workflowInstancePreProcessor.process(instance); long id = workflowInstanceDao.insertWorkflowInstance(processedInstance); if (id == -1 && !isEmpty(instance.externalId)) { QueryWorkflowInstances query = new QueryWorkflowInstances.Builder().addTypes(instance.type).setExternalId(instance.externalId).build(); id = workflowInstanceDao.queryWorkflowInstances(query).get(0).id; } return id; } @Inject  WorkflowInstanceService(WorkflowInstanceDao workflowInstanceDao, WorkflowDefinitionService workflowDefinitionService,
      WorkflowInstancePreProcessor workflowInstancePreProcessor); WorkflowInstance getWorkflowInstance(long id, Set<WorkflowInstanceInclude> includes, Long maxActions); @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "getInitialState().toString() has no cast") long insertWorkflowInstance(WorkflowInstance instance); @Transactional boolean updateWorkflowInstance(WorkflowInstance instance, WorkflowInstanceAction action); @Transactional boolean wakeupWorkflowInstance(long id, List<String> expectedStates); Collection<WorkflowInstance> listWorkflowInstances(QueryWorkflowInstances query); Stream<WorkflowInstance> listWorkflowInstancesAsStream(QueryWorkflowInstances query); Optional<Integer> getSignal(long workflowInstanceId); boolean setSignal(long workflowInstanceId, Optional<Integer> signal, String reason, WorkflowActionType actionType); }
WorkflowInstanceService { @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "getInitialState().toString() has no cast") public long insertWorkflowInstance(WorkflowInstance instance) { Assert.notNull(workflowInstancePreProcessor, "workflowInstancePreProcessor can not be null"); WorkflowInstance processedInstance = workflowInstancePreProcessor.process(instance); long id = workflowInstanceDao.insertWorkflowInstance(processedInstance); if (id == -1 && !isEmpty(instance.externalId)) { QueryWorkflowInstances query = new QueryWorkflowInstances.Builder().addTypes(instance.type).setExternalId(instance.externalId).build(); id = workflowInstanceDao.queryWorkflowInstances(query).get(0).id; } return id; } @Inject  WorkflowInstanceService(WorkflowInstanceDao workflowInstanceDao, WorkflowDefinitionService workflowDefinitionService,
      WorkflowInstancePreProcessor workflowInstancePreProcessor); WorkflowInstance getWorkflowInstance(long id, Set<WorkflowInstanceInclude> includes, Long maxActions); @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "getInitialState().toString() has no cast") long insertWorkflowInstance(WorkflowInstance instance); @Transactional boolean updateWorkflowInstance(WorkflowInstance instance, WorkflowInstanceAction action); @Transactional boolean wakeupWorkflowInstance(long id, List<String> expectedStates); Collection<WorkflowInstance> listWorkflowInstances(QueryWorkflowInstances query); Stream<WorkflowInstance> listWorkflowInstancesAsStream(QueryWorkflowInstances query); Optional<Integer> getSignal(long workflowInstanceId); boolean setSignal(long workflowInstanceId, Optional<Integer> signal, String reason, WorkflowActionType actionType);  }