use of org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl in project activiti-cloud by Activiti.
the class ProcessStartedEventConverterTest method buildProcessStartedEvent.
private CloudProcessStartedEventImpl buildProcessStartedEvent() {
CloudProcessStartedEventImpl cloudAuditEventEntity = new CloudProcessStartedEventImpl("ProcessStartedEventId", System.currentTimeMillis(), new ProcessInstanceImpl());
cloudAuditEventEntity.setAppName("app");
cloudAuditEventEntity.setAppVersion("v2");
cloudAuditEventEntity.setServiceName("service");
cloudAuditEventEntity.setServiceFullName("fullService");
cloudAuditEventEntity.setServiceType("rb");
cloudAuditEventEntity.setServiceVersion("sv1");
cloudAuditEventEntity.setMessageId("msgId");
cloudAuditEventEntity.setSequenceNumber(2);
return cloudAuditEventEntity;
}
use of org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl in project activiti-cloud by Activiti.
the class ProcessStartedEventConverterTest method createEventEntityShouldSetAllNonProcessContextRelatedFields.
@Test
public void createEventEntityShouldSetAllNonProcessContextRelatedFields() {
// given
CloudProcessStartedEventImpl event = buildProcessStartedEvent();
// when
ProcessStartedAuditEventEntity auditEventEntity = eventConverter.createEventEntity(event);
// then
assertThat(auditEventEntity).isNotNull();
assertThat(auditEventEntity.getEventId()).isEqualTo(event.getId());
assertThat(auditEventEntity.getTimestamp()).isEqualTo(event.getTimestamp());
assertThat(auditEventEntity.getAppName()).isEqualTo(event.getAppName());
assertThat(auditEventEntity.getAppVersion()).isEqualTo(event.getAppVersion());
assertThat(auditEventEntity.getServiceName()).isEqualTo(event.getServiceName());
assertThat(auditEventEntity.getServiceFullName()).isEqualTo(event.getServiceFullName());
assertThat(auditEventEntity.getServiceType()).isEqualTo(event.getServiceType());
assertThat(auditEventEntity.getServiceVersion()).isEqualTo(event.getServiceVersion());
assertThat(auditEventEntity.getMessageId()).isEqualTo(event.getMessageId());
assertThat(auditEventEntity.getSequenceNumber()).isEqualTo(event.getSequenceNumber());
assertThat(auditEventEntity.getProcessInstance()).isEqualTo(event.getEntity());
}
use of org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl in project activiti-cloud by Activiti.
the class ProcessStartedEventConverterTest method convertToEntityShouldReturnCreatedEntity.
@Test
public void convertToEntityShouldReturnCreatedEntity() {
// given
ProcessStartedAuditEventEntity auditEventEntity = new ProcessStartedAuditEventEntity();
CloudProcessStartedEventImpl cloudRuntimeEvent = new CloudProcessStartedEventImpl();
doReturn(auditEventEntity).when(eventConverter).createEventEntity(cloudRuntimeEvent);
// when
AuditEventEntity convertedEntity = eventConverter.convertToEntity(cloudRuntimeEvent);
// then
assertThat(convertedEntity).isEqualTo(auditEventEntity);
}
use of org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl in project activiti-cloud by Activiti.
the class ProcessStartedEventConverterTest method createAPIEventShouldSetAllNonProcessContextRelatedFields.
@Test
public void createAPIEventShouldSetAllNonProcessContextRelatedFields() {
// given
CloudProcessStartedEventImpl cloudAuditEventEntity = buildProcessStartedEvent();
ProcessStartedAuditEventEntity auditEventEntity = new ProcessStartedAuditEventEntity(cloudAuditEventEntity);
// when
ProcessStartedEventConverter converter = new ProcessStartedEventConverter(new EventContextInfoAppender());
CloudProcessStartedEventImpl apiEvent = (CloudProcessStartedEventImpl) converter.convertToAPI(auditEventEntity);
assertThat(apiEvent).isNotNull().isInstanceOf(CloudProcessStartedEvent.class);
assertThat(apiEvent.getId()).isEqualTo(auditEventEntity.getEventId());
assertThat(apiEvent.getTimestamp()).isEqualTo(auditEventEntity.getTimestamp());
assertThat(apiEvent.getEntity()).isEqualTo(auditEventEntity.getProcessInstance());
assertThat(apiEvent.getAppName()).isEqualTo(auditEventEntity.getAppName());
assertThat(apiEvent.getAppVersion()).isEqualTo(auditEventEntity.getAppVersion());
assertThat(apiEvent.getServiceFullName()).isEqualTo(auditEventEntity.getServiceFullName());
assertThat(apiEvent.getServiceName()).isEqualTo(auditEventEntity.getServiceName());
assertThat(apiEvent.getServiceType()).isEqualTo(auditEventEntity.getServiceType());
assertThat(apiEvent.getServiceVersion()).isEqualTo(auditEventEntity.getServiceVersion());
assertThat(apiEvent.getMessageId()).isEqualTo(auditEventEntity.getMessageId());
assertThat(apiEvent.getSequenceNumber()).isEqualTo(auditEventEntity.getSequenceNumber());
}
use of org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl in project activiti-cloud by Activiti.
the class MapBuilder method testGraphqlWsSubprotocolServerStartStopSubscription.
@Test
public void testGraphqlWsSubprotocolServerStartStopSubscription() throws JsonProcessingException {
ReplayProcessor<String> data = ReplayProcessor.create();
keycloakTokenProducer.setKeycloakTestUser(TESTADMIN);
final String auth = keycloakTokenProducer.authorizationHeaders().getFirst(AUTHORIZATION);
Map<String, Object> variables = mapBuilder().put("appName", "default-app").put("eventTypes", Arrays.array("PROCESS_CREATED", "PROCESS_STARTED")).get();
Map<String, Object> payload = mapBuilder().put("query", "subscription($appName: String!, $eventTypes: [EngineEventType!]) { " + " engineEvents(appName: [$appName], eventType: $eventTypes) { " + " processInstanceId " + " eventType " + " } " + "}").put("variables", variables).get();
GraphQLMessage start = GraphQLMessage.builder().type(GraphQLMessageType.START).id("1").payload(payload).build();
String startMessage = objectMapper.writeValueAsString(start);
// given
CloudProcessCreatedEvent event1 = new CloudProcessCreatedEventImpl() {
{
setAppName("default-app");
setServiceName("rb-my-app");
setServiceFullName("serviceFullName");
setServiceType("runtime-bundle");
setServiceVersion("");
setProcessInstanceId("processInstanceId");
setProcessDefinitionId("processDefinitionId");
setProcessDefinitionKey("processDefinitionKey");
setProcessDefinitionVersion(1);
setBusinessKey("businessKey");
}
};
CloudProcessStartedEvent event2 = new CloudProcessStartedEventImpl() {
{
setAppName("default-app");
setServiceName("rb-my-app");
setServiceType("runtime-bundle");
setServiceFullName("serviceFullName");
setServiceType("runtime-bundle");
setServiceVersion("");
setProcessInstanceId("processInstanceId");
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, event2)).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(Maps.of("processInstanceId", "processInstanceId", "eventType", "PROCESS_CREATED"), Maps.of("processInstanceId", "processInstanceId", "eventType", "PROCESS_STARTED"))));
String dataMessage = objectMapper.writeValueAsString(GraphQLMessage.builder().type(GraphQLMessageType.DATA).id("1").payload(message).build());
StepVerifier.create(data).expectNext(dataMessage).expectComplete().verify(TIMEOUT);
}
Aggregations