Search in sources :

Example 1 with CloudProcessStartedEventImpl

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;
}
Also used : CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl)

Example 2 with CloudProcessStartedEventImpl

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());
}
Also used : CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) ProcessStartedAuditEventEntity(org.activiti.cloud.services.audit.jpa.events.ProcessStartedAuditEventEntity) Test(org.junit.jupiter.api.Test)

Example 3 with CloudProcessStartedEventImpl

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);
}
Also used : CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) AuditEventEntity(org.activiti.cloud.services.audit.jpa.events.AuditEventEntity) ProcessStartedAuditEventEntity(org.activiti.cloud.services.audit.jpa.events.ProcessStartedAuditEventEntity) ProcessStartedAuditEventEntity(org.activiti.cloud.services.audit.jpa.events.ProcessStartedAuditEventEntity) Test(org.junit.jupiter.api.Test)

Example 4 with CloudProcessStartedEventImpl

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());
}
Also used : CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) ProcessStartedAuditEventEntity(org.activiti.cloud.services.audit.jpa.events.ProcessStartedAuditEventEntity) Test(org.junit.jupiter.api.Test)

Example 5 with CloudProcessStartedEventImpl

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);
}
Also used : CloudProcessStartedEvent(org.activiti.cloud.api.process.model.events.CloudProcessStartedEvent) CloudProcessCreatedEvent(org.activiti.cloud.api.process.model.events.CloudProcessCreatedEvent) CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) CloudProcessCreatedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessCreatedEventImpl) WebsocketSender(reactor.netty.http.client.HttpClient.WebsocketSender) GraphQLMessage(org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

CloudProcessStartedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl)21 ProcessInstanceImpl (org.activiti.api.runtime.model.impl.ProcessInstanceImpl)12 CloudProcessCreatedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCreatedEventImpl)11 Test (org.junit.jupiter.api.Test)10 CloudBPMNActivityCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl)6 CloudBPMNActivityStartedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl)6 BPMNActivityImpl (org.activiti.api.runtime.model.impl.BPMNActivityImpl)5 CloudSequenceFlowTakenEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudSequenceFlowTakenEventImpl)5 BPMNSequenceFlowImpl (org.activiti.api.runtime.model.impl.BPMNSequenceFlowImpl)4 CloudProcessCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCompletedEventImpl)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 ArrayList (java.util.ArrayList)3 ProcessInstance (org.activiti.api.process.model.ProcessInstance)3 CloudRuntimeEvent (org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent)3 CloudProcessSuspendedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessSuspendedEventImpl)3 ProcessStartedAuditEventEntity (org.activiti.cloud.services.audit.jpa.events.ProcessStartedAuditEventEntity)3 CloudProcessInstance (org.activiti.cloud.api.process.model.CloudProcessInstance)2 CloudBPMNActivityCancelledEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCancelledEventImpl)2 CloudIntegrationErrorReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationErrorReceivedEventImpl)2 CloudIntegrationRequestedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationRequestedEventImpl)2