@Test public void testThrowExceptionWhenProcessInstanceNotFound() { given(processInstanceRepository.findById("200")).willReturn(Optional.empty()); expectedException.expect(QueryException.class); expectedException.expectMessage("Unable to find process instance with the given id: "); handler.handle(createProcessCancelledEvent("200")); }
@Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessCancelledEvent cancelledEvent = (CloudProcessCancelledEvent) event; LOGGER.debug("Handling cancel of process Instance " + cancelledEvent.getEntity().getId()); updateProcessInstanceStatus( processInstanceRepository .findById(cancelledEvent.getEntity().getId()) .orElseThrow(() -> new QueryException( "Unable to find process instance with the given id: " + cancelledEvent.getEntity().getId())), cancelledEvent.getTimestamp()); }
ProcessCancelledEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessCancelledEvent cancelledEvent = (CloudProcessCancelledEvent) event; LOGGER.debug("Handling cancel of process Instance " + cancelledEvent.getEntity().getId()); updateProcessInstanceStatus( processInstanceRepository .findById(cancelledEvent.getEntity().getId()) .orElseThrow(() -> new QueryException( "Unable to find process instance with the given id: " + cancelledEvent.getEntity().getId())), cancelledEvent.getTimestamp()); } }
ProcessCancelledEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessCancelledEvent cancelledEvent = (CloudProcessCancelledEvent) event; LOGGER.debug("Handling cancel of process Instance " + cancelledEvent.getEntity().getId()); updateProcessInstanceStatus( processInstanceRepository .findById(cancelledEvent.getEntity().getId()) .orElseThrow(() -> new QueryException( "Unable to find process instance with the given id: " + cancelledEvent.getEntity().getId())), cancelledEvent.getTimestamp()); } ProcessCancelledEventHandler(ProcessInstanceRepository processInstanceRepository); }
ProcessCancelledEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessCancelledEvent cancelledEvent = (CloudProcessCancelledEvent) event; LOGGER.debug("Handling cancel of process Instance " + cancelledEvent.getEntity().getId()); updateProcessInstanceStatus( processInstanceRepository .findById(cancelledEvent.getEntity().getId()) .orElseThrow(() -> new QueryException( "Unable to find process instance with the given id: " + cancelledEvent.getEntity().getId())), cancelledEvent.getTimestamp()); } ProcessCancelledEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent(); }
ProcessCancelledEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessCancelledEvent cancelledEvent = (CloudProcessCancelledEvent) event; LOGGER.debug("Handling cancel of process Instance " + cancelledEvent.getEntity().getId()); updateProcessInstanceStatus( processInstanceRepository .findById(cancelledEvent.getEntity().getId()) .orElseThrow(() -> new QueryException( "Unable to find process instance with the given id: " + cancelledEvent.getEntity().getId())), cancelledEvent.getTimestamp()); } ProcessCancelledEventHandler(ProcessInstanceRepository processInstanceRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent();  }