@Test public void handleShouldUpdateCurrentProcessInstanceStateToRunning() { ProcessInstanceImpl eventProcessInstance = new ProcessInstanceImpl(); eventProcessInstance.setId(UUID.randomUUID().toString()); CloudProcessResumedEvent event = new CloudProcessResumedEventImpl(eventProcessInstance); ProcessInstanceEntity currentProcessInstanceEntity = mock(ProcessInstanceEntity.class); given(processInstanceRepository.findById(eventProcessInstance.getId())).willReturn(Optional.of(currentProcessInstanceEntity)); handler.handle(event); verify(processInstanceRepository).save(currentProcessInstanceEntity); verify(currentProcessInstanceEntity).setStatus(ProcessInstance.ProcessInstanceStatus.RUNNING); verify(currentProcessInstanceEntity).setLastModified(any(Date.class)); }
@Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessResumedEvent processResumedEvent = (CloudProcessResumedEvent) event; String processInstanceId = processResumedEvent.getEntity().getId(); Optional<ProcessInstanceEntity> findResult = processInstanceRepository.findById(processInstanceId); ProcessInstanceEntity processInstanceEntity = findResult.orElseThrow(() -> new QueryException("Unable to find process instance with the given id: " + processInstanceId)); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.RUNNING); processInstanceEntity.setLastModified(new Date(processResumedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); }
ProcessResumedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessResumedEvent processResumedEvent = (CloudProcessResumedEvent) event; String processInstanceId = processResumedEvent.getEntity().getId(); Optional<ProcessInstanceEntity> findResult = processInstanceRepository.findById(processInstanceId); ProcessInstanceEntity processInstanceEntity = findResult.orElseThrow(() -> new QueryException("Unable to find process instance with the given id: " + processInstanceId)); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.RUNNING); processInstanceEntity.setLastModified(new Date(processResumedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } }
ProcessResumedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessResumedEvent processResumedEvent = (CloudProcessResumedEvent) event; String processInstanceId = processResumedEvent.getEntity().getId(); Optional<ProcessInstanceEntity> findResult = processInstanceRepository.findById(processInstanceId); ProcessInstanceEntity processInstanceEntity = findResult.orElseThrow(() -> new QueryException("Unable to find process instance with the given id: " + processInstanceId)); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.RUNNING); processInstanceEntity.setLastModified(new Date(processResumedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessResumedEventHandler(ProcessInstanceRepository processInstanceRepository); }
ProcessResumedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessResumedEvent processResumedEvent = (CloudProcessResumedEvent) event; String processInstanceId = processResumedEvent.getEntity().getId(); Optional<ProcessInstanceEntity> findResult = processInstanceRepository.findById(processInstanceId); ProcessInstanceEntity processInstanceEntity = findResult.orElseThrow(() -> new QueryException("Unable to find process instance with the given id: " + processInstanceId)); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.RUNNING); processInstanceEntity.setLastModified(new Date(processResumedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessResumedEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent(); }
ProcessResumedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessResumedEvent processResumedEvent = (CloudProcessResumedEvent) event; String processInstanceId = processResumedEvent.getEntity().getId(); Optional<ProcessInstanceEntity> findResult = processInstanceRepository.findById(processInstanceId); ProcessInstanceEntity processInstanceEntity = findResult.orElseThrow(() -> new QueryException("Unable to find process instance with the given id: " + processInstanceId)); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.RUNNING); processInstanceEntity.setLastModified(new Date(processResumedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessResumedEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent();  }