Search in sources :

Example 1 with CloudBPMNActivityEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent in project activiti-cloud by Activiti.

the class AuditServiceIT method shouldBeAbleToFilterOnEventTypeActivitiStarted.

@Test
public void shouldBeAbleToFilterOnEventTypeActivitiStarted() {
    // given
    List<CloudRuntimeEvent> coveredEvents = getTestEvents();
    producer.send(coveredEvents.toArray(new CloudRuntimeEvent[coveredEvents.size()]));
    await().untilAsserted(() -> {
        // when
        ResponseEntity<PagedResources<CloudRuntimeEvent>> eventsPagedResources = eventsRestTemplate.executeFind(Collections.singletonMap("eventType", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED.name()));
        // then
        Collection<CloudRuntimeEvent> retrievedEvents = eventsPagedResources.getBody().getContent();
        assertThat(retrievedEvents).hasSize(3);
        for (CloudRuntimeEvent event : retrievedEvents) {
            CloudBPMNActivityEvent cloudBPMNActivityEvent = (CloudBPMNActivityStartedEvent) event;
            assertThat(cloudBPMNActivityEvent.getEventType()).isEqualTo(BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
        }
    });
}
Also used : PagedResources(org.springframework.hateoas.PagedResources) CloudBPMNActivityEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent) 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 CloudBPMNActivityEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent in project activiti-cloud by Activiti.

the class AuditServiceIT method shouldBeAbleToFilterOnProcessInstanceIdAndEventType.

@Test
public void shouldBeAbleToFilterOnProcessInstanceIdAndEventType() {
    // given
    List<CloudRuntimeEvent> coveredEvents = getTestEvents();
    producer.send(coveredEvents.toArray(new CloudRuntimeEvent[coveredEvents.size()]));
    await().untilAsserted(() -> {
        // when
        Map<String, Object> filters = new HashMap<>();
        filters.put("processInstanceId", "4");
        filters.put("eventType", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED.name());
        ResponseEntity<PagedResources<CloudRuntimeEvent>> eventsPagedResources = eventsRestTemplate.executeFind(filters);
        // then
        Collection<CloudRuntimeEvent> retrievedEvents = eventsPagedResources.getBody().getContent();
        assertThat(retrievedEvents).hasSize(2);
        for (CloudRuntimeEvent event : retrievedEvents) {
            CloudBPMNActivityEvent cloudBPMNActivityEvent = (CloudBPMNActivityStartedEvent) event;
            assertThat(cloudBPMNActivityEvent.getEventType()).isEqualTo(BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
        }
    });
}
Also used : HashMap(java.util.HashMap) PagedResources(org.springframework.hateoas.PagedResources) CloudBPMNActivityEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent) 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 CloudBPMNActivityEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent in project activiti-cloud by Activiti.

the class AuditServiceIT method shouldBeAbleToFilterOnProcessInstanceId.

@Test
public void shouldBeAbleToFilterOnProcessInstanceId() {
    // given
    List<CloudRuntimeEvent> coveredEvents = getTestEvents();
    producer.send(coveredEvents.toArray(new CloudRuntimeEvent[coveredEvents.size()]));
    await().untilAsserted(() -> {
        // when
        ResponseEntity<PagedResources<CloudRuntimeEvent>> eventsPagedResources = eventsRestTemplate.executeFind(Collections.singletonMap("processInstanceId", "4"));
        // then
        Collection<CloudRuntimeEvent> retrievedEvents = eventsPagedResources.getBody().getContent();
        assertThat(retrievedEvents).hasSize(2);
        for (CloudRuntimeEvent event : retrievedEvents) {
            CloudBPMNActivityEvent cloudBPMNActivityEvent = (CloudBPMNActivityEvent) event;
            assertThat(cloudBPMNActivityEvent.getProcessInstanceId()).isEqualTo("4");
        }
    });
}
Also used : PagedResources(org.springframework.hateoas.PagedResources) CloudBPMNActivityEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CloudBPMNActivityEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent in project activiti-cloud by Activiti.

the class BaseBPMNActivityEventHandler method findOrCreateBPMNActivityEntity.

protected BPMNActivityEntity findOrCreateBPMNActivityEntity(CloudRuntimeEvent<?, ?> event) {
    CloudBPMNActivityEvent activityEvent = CloudBPMNActivityEvent.class.cast(event);
    BPMNActivity bpmnActivity = activityEvent.getEntity();
    BPMNActivityEntity bpmnActivityEntity = bpmnActivitiyRepository.findByProcessInstanceIdAndElementIdAndExecutionId(bpmnActivity.getProcessInstanceId(), bpmnActivity.getElementId(), bpmnActivity.getExecutionId());
    if (bpmnActivityEntity == null) {
        bpmnActivityEntity = new BPMNActivityEntity(event.getServiceName(), event.getServiceFullName(), event.getServiceVersion(), event.getAppName(), event.getAppVersion());
        // Let use event id to persist activity id
        bpmnActivityEntity.setId(event.getId());
        bpmnActivityEntity.setElementId(bpmnActivity.getElementId());
        bpmnActivityEntity.setActivityName(bpmnActivity.getActivityName());
        bpmnActivityEntity.setActivityType(bpmnActivity.getActivityType());
        bpmnActivityEntity.setProcessDefinitionId(bpmnActivity.getProcessDefinitionId());
        bpmnActivityEntity.setProcessInstanceId(bpmnActivity.getProcessInstanceId());
        bpmnActivityEntity.setExecutionId(bpmnActivity.getExecutionId());
        bpmnActivityEntity.setProcessDefinitionKey(activityEvent.getProcessDefinitionKey());
        bpmnActivityEntity.setProcessDefinitionVersion(activityEvent.getProcessDefinitionVersion());
        bpmnActivityEntity.setBusinessKey(activityEvent.getBusinessKey());
        entityManager.persist(bpmnActivityEntity);
    }
    return bpmnActivityEntity;
}
Also used : BPMNActivity(org.activiti.api.process.model.BPMNActivity) CloudBPMNActivityEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent) BPMNActivityEntity(org.activiti.cloud.services.query.model.BPMNActivityEntity)

Aggregations

CloudBPMNActivityEvent (org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent)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 PagedResources (org.springframework.hateoas.PagedResources)3 CloudBPMNActivityStartedEvent (org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent)2 HashMap (java.util.HashMap)1 BPMNActivity (org.activiti.api.process.model.BPMNActivity)1 BPMNActivityEntity (org.activiti.cloud.services.query.model.BPMNActivityEntity)1