use of org.activiti.engine.delegate.event.ActivitiErrorEvent in project Activiti by Activiti.
the class ToErrorReceivedConverterTest method fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId.
@Test
public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() {
// given
ActivitiErrorEvent internalEvent = mock(ActivitiErrorEvent.class);
given(internalEvent.getProcessDefinitionId()).willReturn("procDefId");
given(internalEvent.getProcessInstanceId()).willReturn("procInstId");
BPMNErrorImpl bpmnError = new BPMNErrorImpl("myError");
given(bpmnErrorConverter.convertToBPMNError(internalEvent)).willReturn(bpmnError);
// when
BPMNErrorReceivedEvent errorEvent = toErrorReceivedConverter.from(internalEvent).orElse(null);
// then
assertThat(errorEvent).isNotNull();
assertThat(errorEvent.getProcessInstanceId()).isEqualTo("procInstId");
assertThat(errorEvent.getProcessDefinitionId()).isEqualTo("procDefId");
assertThat(errorEvent.getEntity()).isEqualTo(bpmnError);
}
use of org.activiti.engine.delegate.event.ActivitiErrorEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityErrorEventsFromBPMNError.
/**
* Test events related to error-events, thrown from within process-execution (eg. service-task).
*/
@Deployment
public void testActivityErrorEventsFromBPMNError() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("errorProcess");
assertThat(processInstance).isNotNull();
// Error-handling should have ended the process
ProcessInstance afterErrorInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertThat(afterErrorInstance).isNull();
List<ActivitiErrorEvent> errorEvents = listener.getEventsReceived().stream().filter(ActivitiErrorEvent.class::isInstance).map(ActivitiErrorEvent.class::cast).collect(toList());
assertThat(errorEvents).as("Only one ActivityErrorEvent expected").hasSize(1);
ActivitiErrorEvent errorEvent = errorEvents.get(0);
assertThat(errorEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_ERROR_RECEIVED);
assertThat(errorEvent.getActivityId()).isEqualTo("catchError");
assertThat(errorEvent.getErrorId()).isEqualTo("23");
assertThat(errorEvent.getErrorCode()).isEqualTo("23");
assertThat(errorEvent.getProcessInstanceId()).isEqualTo(processInstance.getId());
assertThat(errorEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(errorEvent.getExecutionId()).isNotEqualTo(processInstance.getId());
}
use of org.activiti.engine.delegate.event.ActivitiErrorEvent in project Activiti by Activiti.
the class BPMNErrorConverterTest method convertShouldReturnBPMNError.
@Test
public void convertShouldReturnBPMNError() {
ActivitiErrorEvent internalEvent = mock(ActivitiErrorEvent.class);
given(internalEvent.getErrorId()).willReturn("errorId");
given(internalEvent.getErrorCode()).willReturn("errorCode");
given(internalEvent.getActivityName()).willReturn("activityName");
given(internalEvent.getActivityType()).willReturn("activityType");
given(internalEvent.getProcessDefinitionId()).willReturn("procDefId");
given(internalEvent.getProcessInstanceId()).willReturn("procInstId");
BPMNErrorImpl bpmnError = bpmnErrorConverter.convertToBPMNError(internalEvent);
// then
assertThat(bpmnError).isNotNull();
assertThat(bpmnError.getProcessInstanceId()).isEqualTo("procInstId");
assertThat(bpmnError.getProcessDefinitionId()).isEqualTo("procDefId");
assertThat(bpmnError.getErrorId()).isEqualTo("errorId");
assertThat(bpmnError.getErrorCode()).isEqualTo("errorCode");
assertThat(bpmnError.getActivityName()).isEqualTo("activityName");
assertThat(bpmnError.getActivityType()).isEqualTo("activityType");
}
use of org.activiti.engine.delegate.event.ActivitiErrorEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityErrorEvents.
/**
* Test events related to error-events
*/
@Deployment
public void testActivityErrorEvents() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("errorProcess");
assertThat(processInstance).isNotNull();
// Error-handling should have ended the process
ProcessInstance afterErrorInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertThat(afterErrorInstance).isNull();
List<ActivitiErrorEvent> errorEvents = listener.getEventsReceived().stream().filter(ActivitiErrorEvent.class::isInstance).map(ActivitiErrorEvent.class::cast).collect(toList());
assertThat(errorEvents).as("Only one ActivityErrorEvent expected").hasSize(1);
ActivitiErrorEvent errorEvent = errorEvents.get(0);
assertThat(errorEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_ERROR_RECEIVED);
assertThat(errorEvent.getActivityId()).isEqualTo("catchError");
assertThat(errorEvent.getErrorId()).isEqualTo("myError");
assertThat(errorEvent.getErrorCode()).isEqualTo("123");
assertThat(errorEvent.getProcessInstanceId()).isEqualTo(processInstance.getId());
assertThat(errorEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(errorEvent.getExecutionId()).isNotEqualTo(processInstance.getId());
}
Aggregations