use of org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent 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.events.CloudBPMNActivityStartedEvent 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.events.CloudBPMNActivityStartedEvent 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);
}
});
}
use of org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent 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);
}
});
}
use of org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent in project activiti-cloud by Activiti.
the class BPMNActivityStartedEventHandler method handle.
@Override
public void handle(CloudRuntimeEvent<?, ?> event) {
CloudBPMNActivityStartedEvent activityEvent = CloudBPMNActivityStartedEvent.class.cast(event);
BPMNActivityEntity bpmnActivityEntity = findOrCreateBPMNActivityEntity(event);
// Activity can be cyclical, so we just update the status and started date anyways
bpmnActivityEntity.setStartedDate(new Date(activityEvent.getTimestamp()));
bpmnActivityEntity.setStatus(BPMNActivityStatus.STARTED);
}
Aggregations