@Test public void handleShouldUpdateCurrentProcessInstance() { CloudProcessUpdatedEvent event = buildProcessUpdatedEvent(); ProcessInstanceEntity currentProcessInstanceEntity = mock(ProcessInstanceEntity.class); given(processInstanceRepository.findById(event.getEntity().getId())).willReturn(Optional.of(currentProcessInstanceEntity)); handler.handle(event); verify(processInstanceRepository).save(currentProcessInstanceEntity); verify(currentProcessInstanceEntity).setBusinessKey(event.getEntity().getBusinessKey()); verify(currentProcessInstanceEntity).setName(event.getEntity().getName()); verify(currentProcessInstanceEntity).setLastModified(any(Date.class)); verifyNoMoreInteractions(currentProcessInstanceEntity); }
@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();  }