use of org.activiti.engine.delegate.event.ActivitiMessageEvent in project Activiti by Activiti.
the class ActivityMessageEventHandler method generateEventLogEntry.
@Override
public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) {
ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) event;
Map<String, Object> data = new HashMap<String, Object>();
putInMapIfNotNull(data, Fields.ACTIVITY_ID, messageEvent.getActivityId());
putInMapIfNotNull(data, Fields.ACTIVITY_NAME, messageEvent.getActivityName());
putInMapIfNotNull(data, Fields.PROCESS_DEFINITION_ID, messageEvent.getProcessDefinitionId());
putInMapIfNotNull(data, Fields.PROCESS_INSTANCE_ID, messageEvent.getProcessInstanceId());
putInMapIfNotNull(data, Fields.EXECUTION_ID, messageEvent.getExecutionId());
putInMapIfNotNull(data, Fields.ACTIVITY_TYPE, messageEvent.getActivityType());
putInMapIfNotNull(data, Fields.MESSAGE_NAME, messageEvent.getMessageName());
putInMapIfNotNull(data, Fields.MESSAGE_DATA, messageEvent.getMessageData());
return createEventLogEntry(messageEvent.getProcessDefinitionId(), messageEvent.getProcessInstanceId(), messageEvent.getExecutionId(), null, data);
}
use of org.activiti.engine.delegate.event.ActivitiMessageEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityMessageBoundaryEventsOnSubProcess.
/**
* Test events related to message events, called from the API.
*/
@Deployment
public void testActivityMessageBoundaryEventsOnSubProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageOnSubProcess");
assertThat(processInstance).isNotNull();
Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("boundaryMessageEventCatching").singleResult();
assertThat(executionWithMessage).isNotNull();
runtimeService.messageEventReceived("message_1", executionWithMessage.getId());
assertThat(listener.getEventsReceived()).hasSize(4);
// First, an ACTIVITY_MESSAGE_WAITING event is expected
assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiMessageEvent.class);
ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
assertThat(messageEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_WAITING);
assertThat(messageEvent.getActivityId()).isEqualTo("boundaryMessageEventCatching");
assertThat(messageEvent.getExecutionId()).isEqualTo(executionWithMessage.getId());
assertThat(messageEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
assertThat(messageEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(messageEvent.getMessageName()).isEqualTo("message_1");
assertThat(messageEvent.getMessageData()).isNull();
// Second, an ACTIVITY_MESSAGE_RECEIVED event is expected
assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiMessageEvent.class);
messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(1);
assertThat(messageEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
assertThat(messageEvent.getActivityId()).isEqualTo("boundaryMessageEventCatching");
assertThat(messageEvent.getExecutionId()).isEqualTo(executionWithMessage.getId());
assertThat(messageEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
assertThat(messageEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(messageEvent.getMessageName()).isEqualTo("message_1");
assertThat(messageEvent.getMessageData()).isNull();
// Next, a signal-event is expected, as a result of the message
assertThat(listener.getEventsReceived().get(2)).isInstanceOf(ActivitiActivityCancelledEvent.class);
ActivitiActivityCancelledEvent cancelledEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(2);
assertThat(cancelledEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
assertThat(cancelledEvent.getActivityId()).isEqualTo("cloudformtask1");
assertThat(cancelledEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
assertThat(cancelledEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(cancelledEvent.getCause()).isEqualTo("boundary event (boundaryMessageEventCatching)");
assertThat(listener.getEventsReceived().get(3)).isInstanceOf(ActivitiActivityCancelledEvent.class);
cancelledEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(3);
assertThat(cancelledEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_CANCELLED);
assertThat(cancelledEvent.getActivityId()).isEqualTo("subProcess");
assertThat(cancelledEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
assertThat(cancelledEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(cancelledEvent.getCause()).isEqualTo("boundary event (boundaryMessageEventCatching)");
assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
}
use of org.activiti.engine.delegate.event.ActivitiMessageEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityMessageEvents.
/**
* Test events related to message events, called from the API.
*/
@Deployment
public void testActivityMessageEvents() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageProcess");
assertThat(processInstance).isNotNull();
Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("shipOrder").singleResult();
assertThat(executionWithMessage).isNotNull();
runtimeService.messageEventReceived("messageName", executionWithMessage.getId());
assertThat(listener.getEventsReceived()).hasSize(2);
// First, an ACTIVITY_MESSAGE_WAITING event is expected
assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiMessageEvent.class);
ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
assertThat(messageEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_WAITING);
assertThat(messageEvent.getActivityId()).isEqualTo("shipOrder");
assertThat(messageEvent.getExecutionId()).isEqualTo(executionWithMessage.getId());
assertThat(messageEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
assertThat(messageEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(messageEvent.getMessageName()).isEqualTo("messageName");
assertThat(messageEvent.getMessageData()).isNull();
// Second, an ACTIVITY_MESSAGE_RECEIVED event is expected
assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiMessageEvent.class);
messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(1);
assertThat(messageEvent.getType()).isEqualTo(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
assertThat(messageEvent.getActivityId()).isEqualTo("shipOrder");
assertThat(messageEvent.getExecutionId()).isEqualTo(executionWithMessage.getId());
assertThat(messageEvent.getProcessInstanceId()).isEqualTo(executionWithMessage.getProcessInstanceId());
assertThat(messageEvent.getProcessDefinitionId()).isEqualTo(processInstance.getProcessDefinitionId());
assertThat(messageEvent.getMessageName()).isEqualTo("messageName");
assertThat(messageEvent.getMessageData()).isNull();
assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
}
Aggregations