use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl in project activiti-cloud by Activiti.
the class AuditServiceIT method shouldGetSignalReceivedEvent.
@Test
public void shouldGetSignalReceivedEvent() {
// given
List<CloudRuntimeEvent> coveredEvents = new ArrayList<>();
BPMNSignalImpl signal = new BPMNSignalImpl("signalId");
signal.setProcessDefinitionId("processDefinitionId");
signal.setProcessInstanceId("processInstanceId");
SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName("SignalName").withVariable("signal-variable", "test").build();
signal.setSignalPayload(signalPayload);
CloudBPMNSignalReceivedEventImpl cloudSignalReceivedEvent = new CloudBPMNSignalReceivedEventImpl("eventId", System.currentTimeMillis(), signal, signal.getProcessDefinitionId(), signal.getProcessInstanceId());
coveredEvents.add(cloudSignalReceivedEvent);
producer.send(coveredEvents.toArray(new CloudRuntimeEvent[coveredEvents.size()]));
await().untilAsserted(() -> {
// when
Map<String, Object> filters = new HashMap<>();
filters.put("entityId", "signalId");
ResponseEntity<PagedResources<CloudRuntimeEvent>> eventsPagedResources = eventsRestTemplate.executeFind(filters);
// then
Collection<CloudRuntimeEvent> retrievedEvents = eventsPagedResources.getBody().getContent();
assertThat(retrievedEvents).hasSize(1);
assertThat(retrievedEvents).extracting(CloudRuntimeEvent::getEventType, CloudRuntimeEvent::getServiceName, CloudRuntimeEvent::getServiceVersion, CloudRuntimeEvent::getProcessInstanceId, CloudRuntimeEvent::getProcessDefinitionId, CloudRuntimeEvent::getEntityId, event -> ((CloudBPMNSignalReceivedEvent) event).getEntity().getElementId(), event -> ((CloudBPMNSignalReceivedEvent) event).getEntity().getSignalPayload().getId(), event -> ((CloudBPMNSignalReceivedEvent) event).getEntity().getSignalPayload().getName(), event -> ((CloudBPMNSignalReceivedEvent) event).getEntity().getSignalPayload().getVariables()).contains(tuple(cloudSignalReceivedEvent.getEventType(), cloudSignalReceivedEvent.getServiceName(), cloudSignalReceivedEvent.getServiceVersion(), cloudSignalReceivedEvent.getProcessInstanceId(), cloudSignalReceivedEvent.getProcessDefinitionId(), cloudSignalReceivedEvent.getEntityId(), cloudSignalReceivedEvent.getEntity().getElementId(), cloudSignalReceivedEvent.getEntity().getSignalPayload().getId(), cloudSignalReceivedEvent.getEntity().getSignalPayload().getName(), cloudSignalReceivedEvent.getEntity().getSignalPayload().getVariables()));
});
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl in project activiti-cloud by Activiti.
the class SignalReceivedEventConverterTest method checkConvertToAPISignalReceivedEvent.
@Test
public void checkConvertToAPISignalReceivedEvent() {
// given
SignalReceivedAuditEventEntity auditEventEntity = (SignalReceivedAuditEventEntity) eventConverter.convertToEntity(createSignalReceivedEvent());
// when
CloudBPMNSignalReceivedEventImpl cloudEvent = (CloudBPMNSignalReceivedEventImpl) eventConverter.convertToAPI(auditEventEntity);
assertThat(cloudEvent).isNotNull();
assertThat(auditEventEntity.getEntityId()).isEqualTo(cloudEvent.getEntityId());
assertThat(auditEventEntity.getProcessInstanceId()).isEqualTo(cloudEvent.getProcessInstanceId());
assertThat(auditEventEntity.getProcessDefinitionId()).isEqualTo(cloudEvent.getProcessDefinitionId());
assertThat(auditEventEntity.getProcessDefinitionKey()).isEqualTo(cloudEvent.getProcessDefinitionKey());
assertThat(auditEventEntity.getBusinessKey()).isEqualTo(cloudEvent.getBusinessKey());
assertThat(auditEventEntity.getParentProcessInstanceId()).isEqualTo(cloudEvent.getParentProcessInstanceId());
assertThat(auditEventEntity.getSignal().getSignalPayload().getId()).isEqualTo(cloudEvent.getEntity().getSignalPayload().getId());
assertThat(auditEventEntity.getSignal().getSignalPayload().getName()).isEqualTo(cloudEvent.getEntity().getSignalPayload().getName());
assertThat(auditEventEntity.getSignal().getSignalPayload().getVariables()).isEqualTo(cloudEvent.getEntity().getSignalPayload().getVariables());
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl in project activiti-cloud by Activiti.
the class MapBuilder method testGraphqlSubscriptionSIGNAL_RECEIVED.
@Test
public void testGraphqlSubscriptionSIGNAL_RECEIVED() throws JsonProcessingException {
ReplayProcessor<String> data = ReplayProcessor.create();
keycloakTokenProducer.setKeycloakTestUser(TESTADMIN);
final String auth = keycloakTokenProducer.authorizationHeaders().getFirst(AUTHORIZATION);
Map<String, Object> variables = new StringObjectMapBuilder().put("appName", "default-app").put("eventType", "SIGNAL_RECEIVED").get();
Map<String, Object> payload = new StringObjectMapBuilder().put("query", "subscription($appName: String!, $eventType: EngineEventType!) { " + " engineEvents(appName: [$appName], eventType: [$eventType]) { " + " processInstanceId " + " processDefinitionId " + " eventType " + " } " + "}").put("variables", variables).get();
GraphQLMessage start = GraphQLMessage.builder().type(GraphQLMessageType.START).id("1").payload(payload).build();
String startMessage = objectMapper.writeValueAsString(start);
// given
CloudBPMNSignalReceivedEvent event1 = new CloudBPMNSignalReceivedEventImpl("id", new Date().getTime(), new BPMNSignalImpl("elementId"), "processDefinitionId", "processInstanceId") {
{
setAppName("default-app");
setServiceName("rb-my-app");
setServiceFullName("serviceFullName");
setServiceType("runtime-bundle");
setServiceVersion("");
setProcessDefinitionId("processDefinitionId");
setProcessDefinitionKey("processDefinitionKey");
setProcessDefinitionVersion(1);
setBusinessKey("businessKey");
}
};
WebsocketSender client = HttpClient.create().baseUrl("ws://localhost:" + port).wiretap(true).headers(h -> h.add(AUTHORIZATION, auth)).websocket(GRAPHQL_WS).uri(WS_GRAPHQL_URI);
// start subscription
client.handle((i, o) -> {
o.options(NettyPipeline.SendOptions::flushOnEach).sendString(Mono.just(startMessage)).then().log("start").subscribe();
return i.receive().asString().log("data").take(1).doOnSubscribe(s -> producerChannel.output().send(MessageBuilder.withPayload(Arrays.array(event1)).setHeader("routingKey", "eventProducer").build())).delaySubscription(Duration.ofSeconds(1)).subscribeWith(data);
}).collectList().subscribe();
// then
Map<String, Object> message = Maps.of("data", Maps.of("engineEvents", Arrays.array(mapBuilder().put("processInstanceId", "processInstanceId").put("processDefinitionId", "processDefinitionId").put("eventType", "SIGNAL_RECEIVED").get())));
String dataMessage = objectMapper.writeValueAsString(GraphQLMessage.builder().type(GraphQLMessageType.DATA).id("1").payload(message).build());
StepVerifier.create(data).expectNext(dataMessage).expectComplete().verify(TIMEOUT);
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl in project activiti-cloud by Activiti.
the class ToCloudProcessRuntimeEventConverter method from.
public CloudBPMNSignalReceivedEvent from(BPMNSignalReceivedEvent event) {
CloudBPMNSignalReceivedEventImpl cloudEvent = new CloudBPMNSignalReceivedEventImpl(event.getEntity(), event.getEntity().getProcessDefinitionId(), event.getEntity().getProcessInstanceId());
runtimeBundleInfoAppender.appendRuntimeBundleInfoTo(cloudEvent);
return cloudEvent;
}
use of org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl in project activiti-cloud by Activiti.
the class CloudSignalReceivedProducerTest method onEventShouldConvertEventToCloudEventAndAddToAggregator.
@Test
public void onEventShouldConvertEventToCloudEventAndAddToAggregator() {
// given
BPMNSignalReceivedEventImpl event = new BPMNSignalReceivedEventImpl(new BPMNSignalImpl());
CloudBPMNSignalReceivedEventImpl cloudEvent = new CloudBPMNSignalReceivedEventImpl();
given(eventConverter.from(event)).willReturn(cloudEvent);
// when
cloudSignalReceivedProducer.onEvent(event);
// then
verify(eventsAggregator).add(cloudEvent);
}
Aggregations