@Test public void handleShouldUpdateCurrentProcessInstanceStateToSuspended() { CloudProcessSuspendedEvent event = buildProcessSuspendedEvent(); ProcessInstanceEntity currentProcessInstanceEntity = mock(ProcessInstanceEntity.class); given(processInstanceRepository.findById(event.getEntity().getId())).willReturn(Optional.of(currentProcessInstanceEntity)); handler.handle(event); verify(processInstanceRepository).save(currentProcessInstanceEntity); verify(currentProcessInstanceEntity).setStatus(ProcessInstance.ProcessInstanceStatus.SUSPENDED); verify(currentProcessInstanceEntity).setLastModified(any(Date.class)); }
@Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessSuspendedEvent suspendedEvent = (CloudProcessSuspendedEvent) event; String processInstanceId = suspendedEvent.getEntity().getId(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(processInstanceId) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + processInstanceId) ); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.SUSPENDED); processInstanceEntity.setLastModified(new Date(suspendedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); }
ProcessSuspendedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessSuspendedEvent suspendedEvent = (CloudProcessSuspendedEvent) event; String processInstanceId = suspendedEvent.getEntity().getId(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(processInstanceId) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + processInstanceId) ); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.SUSPENDED); processInstanceEntity.setLastModified(new Date(suspendedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } }
ProcessSuspendedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessSuspendedEvent suspendedEvent = (CloudProcessSuspendedEvent) event; String processInstanceId = suspendedEvent.getEntity().getId(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(processInstanceId) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + processInstanceId) ); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.SUSPENDED); processInstanceEntity.setLastModified(new Date(suspendedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessSuspendedEventHandler(ProcessInstanceRepository processInstanceRepository); }
ProcessSuspendedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessSuspendedEvent suspendedEvent = (CloudProcessSuspendedEvent) event; String processInstanceId = suspendedEvent.getEntity().getId(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(processInstanceId) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + processInstanceId) ); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.SUSPENDED); processInstanceEntity.setLastModified(new Date(suspendedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessSuspendedEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent(); }
ProcessSuspendedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessSuspendedEvent suspendedEvent = (CloudProcessSuspendedEvent) event; String processInstanceId = suspendedEvent.getEntity().getId(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(processInstanceId) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + processInstanceId) ); processInstanceEntity.setStatus(ProcessInstance.ProcessInstanceStatus.SUSPENDED); processInstanceEntity.setLastModified(new Date(suspendedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessSuspendedEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent();  }