### Question:
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();  }### Answer:
@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)); }
@Test public void handleShouldThrowExceptionWhenRelatedProcessInstanceIsNotFound() { CloudProcessSuspendedEvent event = buildProcessSuspendedEvent(); given(processInstanceRepository.findById("200")).willReturn(Optional.empty()); expectedException.expect(QueryException.class); expectedException.expectMessage("Unable to find process instance with the given id: "); handler.handle(event); }