Search in sources :

Example 1 with CloudBPMNActivityStartedEventImpl

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");
    });
}
Also used : CloudRuntimeEventImpl(org.activiti.cloud.api.model.shared.impl.events.CloudRuntimeEventImpl) BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) PagedResources(org.springframework.hateoas.PagedResources) CloudBPMNActivityStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl) CloudBPMNActivityStartedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with CloudBPMNActivityStartedEventImpl

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");
    });
}
Also used : BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) CloudBPMNActivityStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl) CloudBPMNActivityStartedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with CloudBPMNActivityStartedEventImpl

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()));
    });
}
Also used : CloudBPMNActivityCompletedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl) BPMNSequenceFlowImpl(org.activiti.api.runtime.model.impl.BPMNSequenceFlowImpl) BPMNSequenceFlowEntity(org.activiti.cloud.services.query.model.BPMNSequenceFlowEntity) BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) CloudSequenceFlowTakenEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudSequenceFlowTakenEventImpl) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) CloudProcessCreatedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessCreatedEventImpl) CloudBPMNActivityStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl) BPMNActivityEntity(org.activiti.cloud.services.query.model.BPMNActivityEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CloudBPMNActivityStartedEventImpl

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;
}
Also used : CloudBPMNActivityCompletedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl) BPMNSequenceFlowImpl(org.activiti.api.runtime.model.impl.BPMNSequenceFlowImpl) BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) CloudSequenceFlowTakenEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudSequenceFlowTakenEventImpl) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) CloudProcessCreatedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessCreatedEventImpl) CloudBPMNActivityStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl)

Example 5 with CloudBPMNActivityStartedEventImpl

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;
}
Also used : CloudBPMNActivityCompletedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl) BPMNSequenceFlowImpl(org.activiti.api.runtime.model.impl.BPMNSequenceFlowImpl) BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) CloudSequenceFlowTakenEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudSequenceFlowTakenEventImpl) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) CloudProcessCreatedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessCreatedEventImpl) CloudBPMNActivityStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl)

Aggregations

CloudBPMNActivityStartedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl)9 BPMNActivityImpl (org.activiti.api.runtime.model.impl.BPMNActivityImpl)7 CloudBPMNActivityCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl)6 CloudProcessStartedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl)6 ProcessInstanceImpl (org.activiti.api.runtime.model.impl.ProcessInstanceImpl)5 CloudProcessCreatedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCreatedEventImpl)5 CloudSequenceFlowTakenEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudSequenceFlowTakenEventImpl)5 BPMNSequenceFlowImpl (org.activiti.api.runtime.model.impl.BPMNSequenceFlowImpl)4 CloudRuntimeEvent (org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ArrayList (java.util.ArrayList)2 CloudBPMNActivityStartedEvent (org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent)2 CloudBPMNActivityCancelledEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCancelledEventImpl)2 CloudIntegrationErrorReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationErrorReceivedEventImpl)2 CloudIntegrationRequestedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationRequestedEventImpl)2 CloudIntegrationResultReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationResultReceivedEventImpl)2 CloudProcessCancelledEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCancelledEventImpl)2 CloudProcessCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCompletedEventImpl)2 CloudProcessDeployedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl)2