use of org.activiti.cloud.starter.tests.services.audit.AuditProducerIT.RUNTIME_BUNDLE_INFO_HEADERS in project activiti-cloud by Activiti.
the class SignalAuditProducerIT method shouldProduceEventsWhenIntermediateSignalIsReceived.
@Test
public void shouldProduceEventsWhenIntermediateSignalIsReceived() {
// given
ResponseEntity<CloudProcessInstance> startProcessEntity1 = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey(SIGNAL_PROCESS).withName("processInstanceName1").withBusinessKey("businessKey1").withVariables(Collections.emptyMap()).build());
ResponseEntity<CloudProcessInstance> startProcessEntity2 = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey(SIGNAL_PROCESS).withName("processInstanceName2").withBusinessKey("businessKey2").withVariables(Collections.emptyMap()).build());
CloudProcessDefinition processWithSignalStart = processDefinitionRestTemplate.getProcessDefinitions().getBody().getContent().stream().filter(cloudProcessDefinition -> cloudProcessDefinition.getKey().equals("processWithSignalStart1")).findAny().orElse(null);
assertThat(processWithSignalStart).isNotNull();
SignalPayload signalProcessInstancesCmd = ProcessPayloadBuilder.signal().withName("Test").withVariable("signalVar", "timeToGo").build();
// when
signalRestTemplate.signal(signalProcessInstancesCmd);
await("Broadcast Signals").untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(RUNTIME_BUNDLE_INFO_HEADERS);
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
String startedBySignalProcessInstanceId = Optional.ofNullable(runtimeService.createProcessInstanceQuery().processDefinitionKey("processWithSignalStart1").singleResult().getId()).orElseThrow(() -> new NoSuchElementException("processWithSignalStart1"));
List<CloudBPMNSignalReceivedEvent> signalReceivedEvents = receivedEvents.stream().filter(CloudBPMNSignalReceivedEvent.class::isInstance).map(CloudBPMNSignalReceivedEvent.class::cast).collect(Collectors.toList());
assertThat(signalReceivedEvents).filteredOn(event -> SIGNAL_RECEIVED.name().equals(event.getEventType().name())).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessDefinitionId, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey, CloudRuntimeEvent::getProcessDefinitionVersion, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId(), event -> event.getEntity().getSignalPayload().getName(), event -> event.getEntity().getSignalPayload().getVariables()).contains(tuple(SIGNAL_RECEIVED, processWithSignalStart.getId(), startedBySignalProcessInstanceId, processWithSignalStart.getKey(), processWithSignalStart.getVersion(), processWithSignalStart.getId(), startedBySignalProcessInstanceId, "theStart", "Test", Collections.singletonMap("signalVar", "timeToGo")), tuple(SIGNAL_RECEIVED, startProcessEntity1.getBody().getProcessDefinitionId(), startProcessEntity1.getBody().getId(), startProcessEntity1.getBody().getProcessDefinitionKey(), // version
1, startProcessEntity1.getBody().getProcessDefinitionId(), startProcessEntity1.getBody().getId(), "signalintermediatecatchevent1", "Test", Collections.singletonMap("signalVar", "timeToGo")), tuple(SIGNAL_RECEIVED, startProcessEntity2.getBody().getProcessDefinitionId(), startProcessEntity2.getBody().getId(), startProcessEntity2.getBody().getProcessDefinitionKey(), // version
1, startProcessEntity2.getBody().getProcessDefinitionId(), startProcessEntity2.getBody().getId(), "signalintermediatecatchevent1", "Test", Collections.singletonMap("signalVar", "timeToGo")));
runtimeService.deleteProcessInstance(startedBySignalProcessInstanceId, "clean up");
});
}
use of org.activiti.cloud.starter.tests.services.audit.AuditProducerIT.RUNTIME_BUNDLE_INFO_HEADERS in project activiti-cloud by Activiti.
the class ErrorAuditProducerIT method should_produceBpmnErrorEvents_when_processIsExecuted.
@Test
public void should_produceBpmnErrorEvents_when_processIsExecuted() {
ResponseEntity<CloudProcessInstance> startProcessEntity = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey(ERROR_START_EVENT_SUBPROCESS).withName("processInstanceName").withBusinessKey("businessKey").build());
assertThat(startProcessEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
CloudProcessInstance processInstance = startProcessEntity.getBody();
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(RUNTIME_BUNDLE_INFO_HEADERS);
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(receivedEvents).filteredOn(event -> (event.getEventType().equals(ACTIVITY_STARTED) || event.getEventType().equals(ACTIVITY_COMPLETED))).extracting(CloudRuntimeEvent::getEventType, event -> ((BPMNActivity) event.getEntity()).getActivityType(), event -> ((BPMNActivity) event.getEntity()).getElementId(), event -> ((BPMNActivity) event.getEntity()).getProcessInstanceId()).contains(tuple(ACTIVITY_STARTED, "endEvent", "subEnd", processInstance.getId()), tuple(ACTIVITY_STARTED, "startEvent", "subStart1", processInstance.getId()), tuple(ACTIVITY_COMPLETED, "startEvent", "subStart1", processInstance.getId()));
assertThat(receivedEvents).filteredOn(CloudBPMNErrorReceivedEvent.class::isInstance).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessDefinitionId, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey, CloudRuntimeEvent::getProcessDefinitionVersion, CloudRuntimeEvent::getBusinessKey, event -> bpmnError(event).getElementId(), event -> bpmnError(event).getProcessDefinitionId(), event -> bpmnError(event).getProcessInstanceId(), event -> bpmnError(event).getErrorCode(), event -> bpmnError(event).getErrorId(), event -> bpmnError(event).getActivityType(), event -> bpmnError(event).getActivityName()).containsExactly(tuple(ERROR_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), processInstance.getProcessDefinitionVersion(), processInstance.getBusinessKey(), "subStart1", processInstance.getProcessDefinitionId(), processInstance.getId(), "123", "errorId", null, null));
});
}
use of org.activiti.cloud.starter.tests.services.audit.AuditProducerIT.RUNTIME_BUNDLE_INFO_HEADERS in project activiti-cloud by Activiti.
the class MessageAuditProducerIT method shouldAuditBPMNEventsMessagesAreProduced.
@Test
public void shouldAuditBPMNEventsMessagesAreProduced() {
// when
ResponseEntity<CloudProcessInstance> startResponse = messageRestTemplate.message(start("auditStartMessage").withBusinessKey("businessId").withVariable("correlationKey", "correlationId").build());
assertThat(startResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(messageRestTemplate.message(receive("auditEventSubprocessMessage").withCorrelationKey("correlationId").build()).getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(messageRestTemplate.message(receive("auditBoundaryMessage").withCorrelationKey("correlationId").withVariable("customerKey", "customerId").build()).getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(messageRestTemplate.message(receive("auditInteremdiateCatchMessage").withCorrelationKey("customerId").withVariable("invoiceKey", "invoiceId").build()).getStatusCode()).isEqualTo(HttpStatus.OK);
// then
CloudProcessInstance processInstance = startResponse.getBody();
await("Audit BPMNMessage Events").untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(RUNTIME_BUNDLE_INFO_HEADERS);
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(receivedEvents).filteredOn(CloudBPMNMessageEvent.class::isInstance).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessDefinitionId, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey, CloudRuntimeEvent::getProcessDefinitionVersion, CloudRuntimeEvent::getBusinessKey, event -> bpmnMessage(event).getElementId(), event -> bpmnMessage(event).getProcessDefinitionId(), event -> bpmnMessage(event).getProcessInstanceId(), event -> bpmnMessage(event).getMessagePayload().getName(), event -> bpmnMessage(event).getMessagePayload().getCorrelationKey(), event -> bpmnMessage(event).getMessagePayload().getBusinessKey(), event -> bpmnMessage(event).getMessagePayload().getVariables()).containsExactly(tuple(MESSAGE_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "startMessageEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditStartMessage", null, processInstance.getBusinessKey(), Collections.singletonMap("correlationKey", "correlationId")), tuple(MESSAGE_WAITING, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "startMessageEventSubprocessEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditEventSubprocessMessage", "correlationId", processInstance.getBusinessKey(), null), tuple(MESSAGE_SENT, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "intermediateThrowMessageEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditIntermediateThrowMessage", "correlationId", processInstance.getBusinessKey(), Collections.singletonMap("correlationKey", "correlationId")), tuple(MESSAGE_WAITING, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "boundaryMessageEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditBoundaryMessage", "correlationId", processInstance.getBusinessKey(), null), tuple(MESSAGE_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "startMessageEventSubprocessEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditEventSubprocessMessage", "correlationId", processInstance.getBusinessKey(), null), tuple(MESSAGE_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "boundaryMessageEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditBoundaryMessage", "correlationId", processInstance.getBusinessKey(), Collections.singletonMap("customerKey", "customerId")), tuple(MESSAGE_WAITING, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "intermediateCatchMessageEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditInteremdiateCatchMessage", "customerId", processInstance.getBusinessKey(), null), tuple(MESSAGE_RECEIVED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "intermediateCatchMessageEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditInteremdiateCatchMessage", "customerId", processInstance.getBusinessKey(), Collections.singletonMap("invoiceKey", "invoiceId")), tuple(MESSAGE_SENT, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), "throwEndMessageEvent", processInstance.getProcessDefinitionId(), processInstance.getId(), "auditThrowEndMessage", "invoiceId", processInstance.getBusinessKey(), Maps.of("correlationKey", "correlationId", "customerKey", "customerId", "invoiceKey", "invoiceId")));
});
}
use of org.activiti.cloud.starter.tests.services.audit.AuditProducerIT.RUNTIME_BUNDLE_INFO_HEADERS in project activiti-cloud by Activiti.
the class MessageAuditProducerIT method should_produceCloudMessageSubscriptionCancelledEvent_when_processIsDeleted.
@Test
public void should_produceCloudMessageSubscriptionCancelledEvent_when_processIsDeleted() {
// when
ResponseEntity<CloudProcessInstance> startProcessEntity = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey(CATCH_MESSAGE).withVariable("correlationKey", "foo").withName("processInstanceName").withBusinessKey("businessKey").build());
assertThat(startProcessEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
CloudProcessInstance processInstance = startProcessEntity.getBody();
await("Audit BPMNMessage Events").untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(RUNTIME_BUNDLE_INFO_HEADERS);
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(receivedEvents).filteredOn(CloudBPMNMessageEvent.class::isInstance).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessDefinitionId, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey, CloudRuntimeEvent::getProcessDefinitionVersion, CloudRuntimeEvent::getBusinessKey, event -> bpmnMessage(event).getProcessDefinitionId(), event -> bpmnMessage(event).getProcessInstanceId(), event -> bpmnMessage(event).getMessagePayload().getName(), event -> bpmnMessage(event).getMessagePayload().getCorrelationKey(), event -> bpmnMessage(event).getMessagePayload().getBusinessKey()).contains(tuple(MESSAGE_WAITING, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), processInstance.getProcessDefinitionId(), processInstance.getId(), "testMessage", "foo", processInstance.getBusinessKey()));
});
ResponseEntity<CloudProcessInstance> deleteProcessEntity = processInstanceRestTemplate.delete(startProcessEntity);
assertThat(deleteProcessEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(RUNTIME_BUNDLE_INFO_HEADERS);
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getAllReceivedEvents();
assertThat(receivedEvents).filteredOn(CloudMessageSubscriptionCancelledEvent.class::isInstance).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getProcessDefinitionId, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey, CloudRuntimeEvent::getProcessDefinitionVersion, CloudRuntimeEvent::getBusinessKey, event -> messageSubscription(event).getProcessDefinitionId(), event -> messageSubscription(event).getProcessInstanceId(), event -> messageSubscription(event).getEventName(), event -> messageSubscription(event).getConfiguration(), event -> messageSubscription(event).getBusinessKey()).contains(tuple(MessageSubscriptionEvent.MessageSubscriptionEvents.MESSAGE_SUBSCRIPTION_CANCELLED, processInstance.getProcessDefinitionId(), processInstance.getId(), processInstance.getProcessDefinitionKey(), // version
1, processInstance.getBusinessKey(), processInstance.getProcessDefinitionId(), processInstance.getId(), "testMessage", "foo", processInstance.getBusinessKey()));
});
}
use of org.activiti.cloud.starter.tests.services.audit.AuditProducerIT.RUNTIME_BUNDLE_INFO_HEADERS in project activiti-cloud by Activiti.
the class TimerAuditProducerIT method shouldGetTimerCanceledEventByProcessDelete.
@Test
public void shouldGetTimerCanceledEventByProcessDelete() {
// GIVEN
ResponseEntity<CloudProcessInstance> startProcessEntity = processInstanceRestTemplate.startProcess(new StartProcessPayloadBuilder().withProcessDefinitionKey(PROCESS_INTERMEDIATE_TIMER_EVENT).withName("processInstanceName").withBusinessKey("businessKey").build());
// WHEN
processInstanceRestTemplate.delete(startProcessEntity);
// when
await().untilAsserted(() -> {
assertThat(streamHandler.getReceivedHeaders()).containsKeys(RUNTIME_BUNDLE_INFO_HEADERS);
assertThat(streamHandler.getReceivedHeaders()).containsKeys(ALL_REQUIRED_HEADERS);
List<CloudRuntimeEvent<?, ?>> receivedEvents = streamHandler.getLatestReceivedEvents();
List<CloudBPMNTimerEvent> timerEvents = receivedEvents.stream().filter(CloudBPMNTimerCancelledEvent.class::isInstance).map(CloudBPMNTimerEvent.class::cast).collect(Collectors.toList());
assertThat(timerEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getBusinessKey, CloudRuntimeEvent::getProcessDefinitionId, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionKey, CloudRuntimeEvent::getProcessDefinitionVersion, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntityId()).contains(tuple(BPMNTimerEvent.TimerEvents.TIMER_CANCELLED, "businessKey", startProcessEntity.getBody().getProcessDefinitionId(), startProcessEntity.getBody().getId(), startProcessEntity.getBody().getProcessDefinitionKey(), startProcessEntity.getBody().getProcessDefinitionVersion(), startProcessEntity.getBody().getProcessDefinitionId(), startProcessEntity.getBody().getId(), "timer"));
});
}
Aggregations