use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl in project activiti-cloud by Activiti.
the class AuditServiceIT method unknownEventShouldNotPreventHandlingOfKnownEvents.
@Test
public void unknownEventShouldNotPreventHandlingOfKnownEvents() {
// given
CloudRuntimeEvent[] events = new CloudRuntimeEvent[2];
BPMNActivityImpl bpmnActivityStarted = new BPMNActivityImpl();
bpmnActivityStarted.setActivityName("first step");
String eventId = "ActivityStartedEventId" + UUID.randomUUID().toString();
CloudBPMNActivityStartedEventImpl cloudBPMNActivityStartedEvent = new CloudBPMNActivityStartedEventImpl(eventId, System.currentTimeMillis(), bpmnActivityStarted, "3", "4");
events[0] = cloudBPMNActivityStartedEvent;
events[1] = new CloudRuntimeEventImpl() {
@Override
public Enum<?> getEventType() {
return IgnoredRuntimeEvent.IgnoredRuntimeEvents.IGNORED;
}
};
producer.send(events);
await().untilAsserted(() -> {
// then
ResponseEntity<PagedResources<CloudRuntimeEvent>> eventsPagedResources = eventsRestTemplate.executeFindAll();
assertThat(eventsPagedResources.getBody()).isNotEmpty();
Collection<CloudRuntimeEvent> retrievedEvents = eventsPagedResources.getBody().getContent();
assertThat(retrievedEvents).hasSize(1);
CloudRuntimeEvent event = retrievedEvents.iterator().next();
// when
assertThat(event).isInstanceOf(CloudBPMNActivityStartedEvent.class);
CloudBPMNActivityStartedEvent cloudProcessStartedEvent = (CloudBPMNActivityStartedEvent) event;
assertThat(cloudProcessStartedEvent.getEventType()).isEqualTo(BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
assertThat(cloudProcessStartedEvent.getProcessDefinitionId()).isEqualTo("3");
assertThat(cloudProcessStartedEvent.getProcessInstanceId()).isEqualTo("4");
assertThat(cloudProcessStartedEvent.getEntity().getActivityName()).isEqualTo("first step");
});
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl in project activiti-cloud by Activiti.
the class AuditServiceIT method findByIdShouldReturnTheEventIdentifiedByTheGivenId.
@Test
public void findByIdShouldReturnTheEventIdentifiedByTheGivenId() {
// given
CloudRuntimeEvent[] events = new CloudRuntimeEvent[1];
BPMNActivityImpl bpmnActivityStarted = new BPMNActivityImpl();
bpmnActivityStarted.setActivityName("first step");
String eventId = "ActivityStartedEventId" + UUID.randomUUID().toString();
CloudBPMNActivityStartedEventImpl cloudBPMNActivityStartedEvent = new CloudBPMNActivityStartedEventImpl(eventId, System.currentTimeMillis(), bpmnActivityStarted, "3", "4");
events[0] = cloudBPMNActivityStartedEvent;
producer.send(events);
await().untilAsserted(() -> {
// when
ResponseEntity<CloudRuntimeEvent> responseEntity = eventsRestTemplate.executeFindById(eventId);
// then
CloudRuntimeEvent event = responseEntity.getBody();
assertThat(event).isInstanceOf(CloudBPMNActivityStartedEvent.class);
CloudBPMNActivityStartedEvent cloudProcessStartedEvent = (CloudBPMNActivityStartedEvent) event;
assertThat(cloudProcessStartedEvent.getEventType()).isEqualTo(BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
assertThat(cloudProcessStartedEvent.getProcessDefinitionId()).isEqualTo("3");
assertThat(cloudProcessStartedEvent.getProcessInstanceId()).isEqualTo("4");
assertThat(cloudProcessStartedEvent.getEntity().getActivityName()).isEqualTo("first step");
});
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl in project activiti-cloud by Activiti.
the class QueryProcessDiagramIT method shouldHandleBPMNDiagramEvents.
@Test
public void shouldHandleBPMNDiagramEvents() throws InterruptedException {
// given
ProcessInstanceImpl process = new ProcessInstanceImpl();
process.setId(UUID.randomUUID().toString());
process.setName("process");
process.setProcessDefinitionKey("mySimpleProcess2");
process.setProcessDefinitionId(processDefinitionId2);
process.setProcessDefinitionVersion(1);
BPMNActivityImpl startActivity = new BPMNActivityImpl("startEvent1", "", "startEvent");
startActivity.setProcessDefinitionId(process.getProcessDefinitionId());
startActivity.setProcessInstanceId(process.getId());
BPMNSequenceFlowImpl sequenceFlow = new BPMNSequenceFlowImpl("sid-68945AF1-396F-4B8A-B836-FC318F62313F", "startEvent1", "sid-CDFE7219-4627-43E9-8CA8-866CC38EBA94");
sequenceFlow.setProcessDefinitionId(process.getProcessDefinitionId());
sequenceFlow.setProcessInstanceId(process.getId());
BPMNActivityImpl taskActivity = new BPMNActivityImpl("sid-CDFE7219-4627-43E9-8CA8-866CC38EBA94", "Perform Action", "userTask");
taskActivity.setProcessDefinitionId(process.getProcessDefinitionId());
taskActivity.setProcessInstanceId(process.getId());
eventsAggregator.addEvents(new CloudProcessCreatedEventImpl(process), new CloudProcessStartedEventImpl(process, null, null), new CloudBPMNActivityStartedEventImpl(startActivity, processDefinitionId, process.getId()), new CloudBPMNActivityCompletedEventImpl(startActivity, processDefinitionId, process.getId()), new CloudSequenceFlowTakenEventImpl(sequenceFlow), new CloudBPMNActivityStartedEventImpl(taskActivity, processDefinitionId, process.getId()));
// when
eventsAggregator.sendAll();
// then
await().untilAsserted(() -> {
List<BPMNActivityEntity> activities = bpmnActivityRepository.findByProcessInstanceId(process.getId());
assertThat(activities).hasSize(2);
assertThat(activities).extracting(BPMNActivityEntity::getElementId, BPMNActivityEntity::getActivityType, BPMNActivityEntity::getStatus).containsExactly(tuple(startActivity.getElementId(), startActivity.getActivityType(), BPMNActivityEntity.BPMNActivityStatus.COMPLETED), tuple(taskActivity.getElementId(), taskActivity.getActivityType(), BPMNActivityEntity.BPMNActivityStatus.STARTED));
List<BPMNSequenceFlowEntity> sequenceFlows = bpmnSequenceFlowRepository.findByProcessInstanceId(process.getId());
assertThat(sequenceFlows).hasSize(1);
assertThat(sequenceFlows).extracting(BPMNSequenceFlowEntity::getElementId, BPMNSequenceFlowEntity::getSourceActivityElementId, BPMNSequenceFlowEntity::getTargetActivityElementId).containsExactly(tuple(sequenceFlow.getElementId(), sequenceFlow.getSourceActivityElementId(), sequenceFlow.getTargetActivityElementId()));
});
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl in project activiti-cloud by Activiti.
the class QueryProcessDiagramIT method startAnotherProcessInstance.
protected ProcessInstanceImpl startAnotherProcessInstance() {
ProcessInstanceImpl process = new ProcessInstanceImpl();
process.setId(UUID.randomUUID().toString());
process.setName("process");
process.setProcessDefinitionKey("mySimpleProcess2");
process.setProcessDefinitionId(processDefinitionId2);
process.setProcessDefinitionVersion(1);
BPMNActivityImpl startActivity = new BPMNActivityImpl("startEvent1", "", "startEvent");
startActivity.setProcessDefinitionId(process.getProcessDefinitionId());
startActivity.setProcessInstanceId(process.getId());
startActivity.setExecutionId(UUID.randomUUID().toString());
BPMNSequenceFlowImpl sequenceFlow = new BPMNSequenceFlowImpl("sid-68945AF1-396F-4B8A-B836-FC318F62313F", "startEvent1", "sid-CDFE7219-4627-43E9-8CA8-866CC38EBA94");
sequenceFlow.setProcessDefinitionId(process.getProcessDefinitionId());
sequenceFlow.setProcessInstanceId(process.getId());
BPMNActivityImpl taskActivity = new BPMNActivityImpl("sid-CDFE7219-4627-43E9-8CA8-866CC38EBA94", "Perform Action", "userTask");
taskActivity.setProcessDefinitionId(process.getProcessDefinitionId());
taskActivity.setProcessInstanceId(process.getId());
taskActivity.setExecutionId(UUID.randomUUID().toString());
eventsAggregator.addEvents(new CloudProcessCreatedEventImpl(process), new CloudProcessStartedEventImpl(process, null, null), new CloudBPMNActivityStartedEventImpl(startActivity, processDefinitionId, process.getId()), new CloudBPMNActivityCompletedEventImpl(startActivity, processDefinitionId, process.getId()), new CloudSequenceFlowTakenEventImpl(sequenceFlow), new CloudBPMNActivityStartedEventImpl(taskActivity, processDefinitionId, process.getId()));
return process;
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl in project activiti-cloud by Activiti.
the class QueryAdminProcessDiagramIT method startSimpleProcessInstance.
protected ProcessInstanceImpl startSimpleProcessInstance() {
ProcessInstanceImpl process = new ProcessInstanceImpl();
process.setId(UUID.randomUUID().toString());
process.setName("process");
process.setProcessDefinitionKey("mySimpleProcess");
process.setProcessDefinitionId(processDefinitionId);
process.setProcessDefinitionVersion(1);
BPMNActivityImpl startActivity = new BPMNActivityImpl("startEvent1", "", "startEvent");
startActivity.setProcessDefinitionId(process.getProcessDefinitionId());
startActivity.setProcessInstanceId(process.getId());
startActivity.setExecutionId(UUID.randomUUID().toString());
BPMNSequenceFlowImpl sequenceFlow = new BPMNSequenceFlowImpl("sid-68945AF1-396F-4B8A-B836-FC318F62313F", "startEvent1", "sid-CDFE7219-4627-43E9-8CA8-866CC38EBA94");
sequenceFlow.setProcessDefinitionId(process.getProcessDefinitionId());
sequenceFlow.setProcessInstanceId(process.getId());
BPMNActivityImpl taskActivity = new BPMNActivityImpl("sid-CDFE7219-4627-43E9-8CA8-866CC38EBA94", "Perform Action", "userTask");
taskActivity.setProcessDefinitionId(process.getProcessDefinitionId());
taskActivity.setProcessInstanceId(process.getId());
taskActivity.setExecutionId(UUID.randomUUID().toString());
eventsAggregator.addEvents(new CloudProcessCreatedEventImpl(process), new CloudProcessStartedEventImpl(process, null, null), new CloudBPMNActivityStartedEventImpl(startActivity, processDefinitionId, process.getId()), new CloudBPMNActivityCompletedEventImpl(startActivity, processDefinitionId, process.getId()), new CloudSequenceFlowTakenEventImpl(sequenceFlow), new CloudBPMNActivityStartedEventImpl(taskActivity, processDefinitionId, process.getId()));
return process;
}
Aggregations