### Question:
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();  }### Answer:
@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)); }
@Test public void handleShouldThrowExceptionWhenRelatedProcessInstanceIsNotFound() { ProcessInstanceImpl eventProcessInstance = new ProcessInstanceImpl(); eventProcessInstance.setId(UUID.randomUUID().toString()); CloudProcessResumedEvent event = new CloudProcessResumedEventImpl(eventProcessInstance); given(processInstanceRepository.findById(eventProcessInstance.getId())).willReturn(Optional.empty()); expectedException.expect(QueryException.class); expectedException.expectMessage("Unable to find process instance with the given id: "); handler.handle(event); }