@Test public void handleShouldThrowExceptionWhenRelatedProcessInstanceIsNotFound() { CloudProcessUpdatedEvent event = buildProcessUpdatedEvent(); String id = event.getEntity().getId(); given(processInstanceRepository.findById(id)).willReturn(Optional.empty()); expectedException.expect(QueryException.class); expectedException.expectMessage("Unable to find process instance with the given id: "); handler.handle(event); }
@Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessUpdatedEvent updatedEvent = (CloudProcessUpdatedEvent) event; ProcessInstance eventProcessInstance = updatedEvent.getEntity(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(eventProcessInstance.getId()) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + eventProcessInstance.getId()) ); processInstanceEntity.setBusinessKey(eventProcessInstance.getBusinessKey()); processInstanceEntity.setName(eventProcessInstance.getName()); processInstanceEntity.setLastModified(new Date(updatedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); }
ProcessUpdatedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessUpdatedEvent updatedEvent = (CloudProcessUpdatedEvent) event; ProcessInstance eventProcessInstance = updatedEvent.getEntity(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(eventProcessInstance.getId()) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + eventProcessInstance.getId()) ); processInstanceEntity.setBusinessKey(eventProcessInstance.getBusinessKey()); processInstanceEntity.setName(eventProcessInstance.getName()); processInstanceEntity.setLastModified(new Date(updatedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } }
ProcessUpdatedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessUpdatedEvent updatedEvent = (CloudProcessUpdatedEvent) event; ProcessInstance eventProcessInstance = updatedEvent.getEntity(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(eventProcessInstance.getId()) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + eventProcessInstance.getId()) ); processInstanceEntity.setBusinessKey(eventProcessInstance.getBusinessKey()); processInstanceEntity.setName(eventProcessInstance.getName()); processInstanceEntity.setLastModified(new Date(updatedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessUpdatedEventHandler(ProcessInstanceRepository processInstanceRepository); }
ProcessUpdatedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessUpdatedEvent updatedEvent = (CloudProcessUpdatedEvent) event; ProcessInstance eventProcessInstance = updatedEvent.getEntity(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(eventProcessInstance.getId()) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + eventProcessInstance.getId()) ); processInstanceEntity.setBusinessKey(eventProcessInstance.getBusinessKey()); processInstanceEntity.setName(eventProcessInstance.getName()); processInstanceEntity.setLastModified(new Date(updatedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessUpdatedEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent(); }
ProcessUpdatedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessUpdatedEvent updatedEvent = (CloudProcessUpdatedEvent) event; ProcessInstance eventProcessInstance = updatedEvent.getEntity(); ProcessInstanceEntity processInstanceEntity = processInstanceRepository.findById(eventProcessInstance.getId()) .orElseThrow( () -> new QueryException("Unable to find process instance with the given id: " + eventProcessInstance.getId()) ); processInstanceEntity.setBusinessKey(eventProcessInstance.getBusinessKey()); processInstanceEntity.setName(eventProcessInstance.getName()); processInstanceEntity.setLastModified(new Date(updatedEvent.getTimestamp())); processInstanceRepository.save(processInstanceEntity); } ProcessUpdatedEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent();  }