Search in sources :

Example 1 with CloudBPMNSignalReceivedEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent 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()));
    });
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) CloudMessageSubscriptionCancelledEvent(org.activiti.cloud.api.process.model.events.CloudMessageSubscriptionCancelledEvent) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) CloudTaskCreatedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCreatedEventImpl) IgnoredRuntimeEvent(org.activiti.cloud.api.model.shared.impl.conf.IgnoredRuntimeEvent) Task(org.activiti.api.task.model.Task) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent) CloudProcessStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl) CloudProcessCompletedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessCompletedEventImpl) CloudTaskCandidateUserAddedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserAddedEventImpl) Autowired(org.springframework.beans.factory.annotation.Autowired) BPMNTimerEvent(org.activiti.api.process.model.events.BPMNTimerEvent) PagedResources(org.springframework.hateoas.PagedResources) Map(java.util.Map) BPMNErrorReceivedEvent(org.activiti.api.process.model.events.BPMNErrorReceivedEvent) CloudIntegrationErrorReceivedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudIntegrationErrorReceivedEventImpl) Awaitility.await(org.awaitility.Awaitility.await) CloudIntegrationResultReceivedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudIntegrationResultReceivedEventImpl) IntegrationContextImpl(org.activiti.api.runtime.model.impl.IntegrationContextImpl) BPMNTimerImpl(org.activiti.api.runtime.model.impl.BPMNTimerImpl) Collection(java.util.Collection) TaskImpl(org.activiti.api.task.model.impl.TaskImpl) CloudBPMNSignalReceivedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl) CloudTaskAssignedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskAssignedEventImpl) BPMNActivityEvent(org.activiti.api.process.model.events.BPMNActivityEvent) CloudProcessCancelledEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessCancelledEventImpl) TestPropertySource(org.springframework.test.context.TestPropertySource) UUID(java.util.UUID) MessageSubscriptionCancelledEvent(org.activiti.api.process.model.events.MessageSubscriptionCancelledEvent) Test(org.junit.jupiter.api.Test) List(java.util.List) CloudRuntimeEventImpl(org.activiti.cloud.api.model.shared.impl.events.CloudRuntimeEventImpl) CloudProcessSuspendedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessSuspendedEventImpl) CloudTaskCompletedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCompletedEventImpl) CloudBPMNErrorReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNErrorReceivedEvent) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) CloudBPMNActivityEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityEvent) CloudBPMNActivityCompletedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl) TaskCandidateUserEvent(org.activiti.api.task.model.events.TaskCandidateUserEvent) EventsRepository(org.activiti.cloud.services.audit.jpa.repository.EventsRepository) BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) CloudProcessDeployedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl) TaskCandidateUserImpl(org.activiti.api.task.model.impl.TaskCandidateUserImpl) CloudTaskCancelledEvent(org.activiti.cloud.api.task.model.events.CloudTaskCancelledEvent) HashMap(java.util.HashMap) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) CloudTaskCancelledEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCancelledEventImpl) ArrayList(java.util.ArrayList) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) CloudTaskCreatedEvent(org.activiti.cloud.api.task.model.events.CloudTaskCreatedEvent) CloudIntegrationRequestedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudIntegrationRequestedEventImpl) CloudTaskCandidateUserRemovedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserRemovedEventImpl) TaskRuntimeEvent(org.activiti.api.task.model.events.TaskRuntimeEvent) CloudBPMNTimerScheduledEvent(org.activiti.cloud.api.process.model.events.CloudBPMNTimerScheduledEvent) CloudBPMNSignalReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent) CloudProcessUpdatedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessUpdatedEventImpl) MyProducer(org.activiti.cloud.starters.test.MyProducer) Assertions.tuple(org.assertj.core.api.Assertions.tuple) CloudBPMNActivityStartedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNActivityStartedEvent) Import(org.springframework.context.annotation.Import) BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) CloudBPMNActivityCancelledEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCancelledEventImpl) TimerPayload(org.activiti.api.process.model.payloads.TimerPayload) BPMNErrorImpl(org.activiti.api.runtime.model.impl.BPMNErrorImpl) CloudTaskAssignedEvent(org.activiti.cloud.api.task.model.events.CloudTaskAssignedEvent) CloudTaskUpdatedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskUpdatedEventImpl) CloudBPMNActivityStartedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl) CloudBPMNTimerScheduledEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNTimerScheduledEventImpl) CloudBPMNErrorReceivedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNErrorReceivedEventImpl) CloudBPMNTimerFiredEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNTimerFiredEventImpl) ResponseEntity(org.springframework.http.ResponseEntity) MessageSubscriptionImpl(org.activiti.api.runtime.model.impl.MessageSubscriptionImpl) Collections(java.util.Collections) CloudMessageSubscriptionCancelledEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudMessageSubscriptionCancelledEventImpl) HashMap(java.util.HashMap) PagedResources(org.springframework.hateoas.PagedResources) ArrayList(java.util.ArrayList) BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) CloudBPMNSignalReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent) CloudBPMNSignalReceivedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with CloudBPMNSignalReceivedEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent 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);
}
Also used : BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) CloudBPMNSignalReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent) WebsocketSender(reactor.netty.http.client.HttpClient.WebsocketSender) GraphQLMessage(org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage) CloudBPMNSignalReceivedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl) Date(java.util.Date) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with CloudBPMNSignalReceivedEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent 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");
    });
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) DirtiesContext(org.springframework.test.annotation.DirtiesContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent) Autowired(org.springframework.beans.factory.annotation.Autowired) CloudProcessInstance(org.activiti.cloud.api.process.model.CloudProcessInstance) ActiveProfiles(org.springframework.test.context.ActiveProfiles) ALL_REQUIRED_HEADERS(org.activiti.cloud.starter.tests.services.audit.AuditProducerIT.ALL_REQUIRED_HEADERS) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) SignalRestTemplate(org.activiti.cloud.starter.tests.helper.SignalRestTemplate) ProcessDefinitionRestTemplate(org.activiti.cloud.starter.tests.helper.ProcessDefinitionRestTemplate) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) ACTIVITY_STARTED(org.activiti.api.process.model.events.BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) NoSuchElementException(java.util.NoSuchElementException) SIGNAL_RECEIVED(org.activiti.api.process.model.events.BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED) CloudBPMNSignalReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent) Awaitility.await(org.awaitility.Awaitility.await) PROCESS_STARTED(org.activiti.api.process.model.events.ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED) Assertions.tuple(org.assertj.core.api.Assertions.tuple) PROCESS_COMPLETED(org.activiti.api.process.model.events.ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED) TestPropertySource(org.springframework.test.context.TestPropertySource) PROCESS_CREATED(org.activiti.api.process.model.events.ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED) SEQUENCE_FLOW_TAKEN(org.activiti.api.process.model.events.SequenceFlowEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) ProcessInstanceRestTemplate(org.activiti.cloud.starter.tests.helper.ProcessInstanceRestTemplate) List(java.util.List) ACTIVITY_COMPLETED(org.activiti.api.process.model.events.BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Optional(java.util.Optional) ResponseEntity(org.springframework.http.ResponseEntity) StartProcessPayloadBuilder(org.activiti.api.process.model.builders.StartProcessPayloadBuilder) RUNTIME_BUNDLE_INFO_HEADERS(org.activiti.cloud.starter.tests.services.audit.AuditProducerIT.RUNTIME_BUNDLE_INFO_HEADERS) Collections(java.util.Collections) CloudProcessInstance(org.activiti.cloud.api.process.model.CloudProcessInstance) StartProcessPayloadBuilder(org.activiti.api.process.model.builders.StartProcessPayloadBuilder) CloudBPMNSignalReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CloudBPMNSignalReceivedEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent in project activiti-cloud by Activiti.

the class MapBuilder method testGraphqlSubscriptionShouldFilterEmptyResults.

@Test
public void testGraphqlSubscriptionShouldFilterEmptyResults() 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", "PROCESS_STARTED").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").timeout(Duration.ofSeconds(2)).doOnSubscribe(s -> producerChannel.output().send(MessageBuilder.withPayload(Arrays.array(event1)).setHeader("routingKey", "eventProducer").build())).delaySubscription(Duration.ofSeconds(1)).subscribeWith(data);
    }).collectList().subscribe();
    StepVerifier.create(data).expectSubscription().expectError(TimeoutException.class).verify();
}
Also used : BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) GraphQLMessage(org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage) Date(java.util.Date) CloudBPMNSignalReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent) WebsocketSender(reactor.netty.http.client.HttpClient.WebsocketSender) CloudBPMNSignalReceivedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with CloudBPMNSignalReceivedEvent

use of org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent in project activiti-cloud by Activiti.

the class ToCloudProcessRuntimeEventConverterTest method shouldConvertBPMNSignalReceivedEventToCloudBPMNSignalReceivedEvent.

@Test
public void shouldConvertBPMNSignalReceivedEventToCloudBPMNSignalReceivedEvent() {
    // given
    BPMNSignalImpl signal = new BPMNSignalImpl();
    signal.setProcessDefinitionId("procDefId");
    signal.setProcessInstanceId("procInstId");
    BPMNSignalReceivedEventImpl signalReceivedEvent = new BPMNSignalReceivedEventImpl(signal);
    // when
    CloudBPMNSignalReceivedEvent cloudEvent = converter.from(signalReceivedEvent);
    assertThat(cloudEvent.getEntity()).isEqualTo(signal);
    assertThat(cloudEvent.getProcessDefinitionId()).isEqualTo("procDefId");
    assertThat(cloudEvent.getProcessInstanceId()).isEqualTo("procInstId");
    // then
    verify(runtimeBundleInfoAppender).appendRuntimeBundleInfoTo(any(CloudRuntimeEventImpl.class));
}
Also used : CloudRuntimeEventImpl(org.activiti.cloud.api.model.shared.impl.events.CloudRuntimeEventImpl) BPMNSignalReceivedEventImpl(org.activiti.api.runtime.event.impl.BPMNSignalReceivedEventImpl) BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) CloudBPMNSignalReceivedEvent(org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent) Test(org.junit.jupiter.api.Test)

Aggregations

CloudBPMNSignalReceivedEvent (org.activiti.cloud.api.process.model.events.CloudBPMNSignalReceivedEvent)5 Test (org.junit.jupiter.api.Test)5 BPMNSignalImpl (org.activiti.api.runtime.model.impl.BPMNSignalImpl)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 CloudBPMNSignalReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl)3 Collections (java.util.Collections)2 Date (java.util.Date)2 List (java.util.List)2 ProcessPayloadBuilder (org.activiti.api.process.model.builders.ProcessPayloadBuilder)2 SignalPayload (org.activiti.api.process.model.payloads.SignalPayload)2 CloudRuntimeEvent (org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.tuple (org.assertj.core.api.Assertions.tuple)2 Awaitility.await (org.awaitility.Awaitility.await)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 ResponseEntity (org.springframework.http.ResponseEntity)2 DirtiesContext (org.springframework.test.annotation.DirtiesContext)2 TestPropertySource (org.springframework.test.context.TestPropertySource)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1