Search in sources :

Example 1 with CloudProcessDeployedEventImpl

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

the class MapBuilder method testGraphqlSubscriptionPROCESS_DEPLOYED.

@Test
public void testGraphqlSubscriptionPROCESS_DEPLOYED() 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").get();
    Map<String, Object> payload = new StringObjectMapBuilder().put("query", "subscription($appName: String!) { " + "  engineEvents(appName: [$appName], eventType: PROCESS_DEPLOYED) { " + "    processDefinitionKey " + "    eventType " + "  } " + "}").put("variables", variables).get();
    GraphQLMessage start = GraphQLMessage.builder().type(GraphQLMessageType.START).id("1").payload(payload).build();
    String startMessage = objectMapper.writeValueAsString(start);
    // given
    CloudProcessDeployedEvent event1 = new CloudProcessDeployedEventImpl("id", new Date().getTime(), new ProcessDefinitionEntity()) {

        {
            setAppName("default-app");
            setServiceName("rb-my-app");
            setServiceFullName("serviceFullName");
            setServiceType("runtime-bundle");
            setServiceVersion("");
            setProcessDefinitionId("processDefinitionId");
            setProcessDefinitionKey("processDefinitionKey");
            setProcessDefinitionVersion(1);
            setProcessModelContent("processModelContent");
            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("processDefinitionKey", "processDefinitionKey").put("eventType", "PROCESS_DEPLOYED").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 : CloudProcessDeployedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl) ProcessDefinitionEntity(org.activiti.cloud.services.query.model.ProcessDefinitionEntity) WebsocketSender(reactor.netty.http.client.HttpClient.WebsocketSender) GraphQLMessage(org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage) Date(java.util.Date) CloudProcessDeployedEvent(org.activiti.cloud.api.process.model.events.CloudProcessDeployedEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with CloudProcessDeployedEventImpl

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

the class QueryAdminProcessDefinitionIT method shouldGetAvailableProcessDefinitions.

@Test
public void shouldGetAvailableProcessDefinitions() {
    // given
    ProcessDefinitionImpl firstProcessDefinition = new ProcessDefinitionImpl();
    firstProcessDefinition.setId(UUID.randomUUID().toString());
    firstProcessDefinition.setKey("myFirstProcess");
    firstProcessDefinition.setName("My First Process");
    ProcessDefinitionImpl secondProcessDefinition = new ProcessDefinitionImpl();
    secondProcessDefinition.setId(UUID.randomUUID().toString());
    secondProcessDefinition.setKey("mySecondProcess");
    secondProcessDefinition.setName("My second Process");
    producer.send(new CloudProcessDeployedEventImpl(firstProcessDefinition), new CloudProcessDeployedEventImpl(secondProcessDefinition));
    // when
    ResponseEntity<PagedResources<CloudProcessDefinition>> responseEntity = testRestTemplate.getProcDefinitions();
    // then
    assertThat(responseEntity.getBody()).isNotNull().extracting(ProcessDefinition::getId, ProcessDefinition::getName, ProcessDefinition::getKey).containsExactly(tuple(firstProcessDefinition.getId(), "My First Process", "myFirstProcess"), tuple(secondProcessDefinition.getId(), "My second Process", "mySecondProcess"));
}
Also used : CloudProcessDeployedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl) ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) PagedResources(org.springframework.hateoas.PagedResources) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with CloudProcessDeployedEventImpl

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

the class QueryAdminProcessDefinitionIT method shouldGetAvailableProcessModels.

@Test
public void shouldGetAvailableProcessModels() throws Exception {
    // given
    ProcessDefinitionImpl firstProcessDefinition = new ProcessDefinitionImpl();
    firstProcessDefinition.setId(UUID.randomUUID().toString());
    firstProcessDefinition.setKey("myFirstProcess");
    firstProcessDefinition.setName("My First Process");
    ProcessDefinitionImpl secondProcessDefinition = new ProcessDefinitionImpl();
    secondProcessDefinition.setId(UUID.randomUUID().toString());
    secondProcessDefinition.setKey("mySecondProcess");
    secondProcessDefinition.setName("My second Process");
    CloudProcessDeployedEventImpl firstProcessDeployedEvent = new CloudProcessDeployedEventImpl(firstProcessDefinition);
    firstProcessDeployedEvent.setProcessModelContent(StreamUtils.copyToString(Thread.currentThread().getContextClassLoader().getResourceAsStream("parse-for-test/processWithVariables.bpmn20.xml"), StandardCharsets.UTF_8));
    CloudProcessDeployedEventImpl secondProcessDeployedEvent = new CloudProcessDeployedEventImpl(secondProcessDefinition);
    secondProcessDeployedEvent.setProcessModelContent(StreamUtils.copyToString(Thread.currentThread().getContextClassLoader().getResourceAsStream("parse-for-test/SimpleProcess.bpmn20.xml"), StandardCharsets.UTF_8));
    producer.send(firstProcessDeployedEvent, secondProcessDeployedEvent);
    // when
    ResponseEntity<String> responseEntity = testRestTemplate.getProcDefinitionModel(firstProcessDefinition.getId());
    // then
    assertThat(responseEntity.getBody()).isXmlEqualToContentOf(new File("src/test/resources/parse-for-test/processWithVariables.bpmn20.xml"));
    // when
    responseEntity = testRestTemplate.getProcDefinitionModel(secondProcessDefinition.getId());
    // then
    assertThat(responseEntity.getBody()).isXmlEqualToContentOf(new File("src/test/resources/parse-for-test/SimpleProcess.bpmn20.xml"));
}
Also used : CloudProcessDeployedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl) ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) File(java.io.File) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CloudProcessDeployedEventImpl

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

the class QueryProcessDefinitionIT method shouldGetAvailableProcessDefinitions.

@Test
public void shouldGetAvailableProcessDefinitions() {
    // given
    ProcessDefinitionImpl firstProcessDefinition = new ProcessDefinitionImpl();
    firstProcessDefinition.setId(UUID.randomUUID().toString());
    firstProcessDefinition.setKey("myFirstProcessKey");
    firstProcessDefinition.setName("My First Process");
    ProcessDefinitionImpl secondProcessDefinition = new ProcessDefinitionImpl();
    secondProcessDefinition.setId(UUID.randomUUID().toString());
    secondProcessDefinition.setKey("mySecondProcess");
    secondProcessDefinition.setName("My second Process");
    producer.send(new CloudProcessDeployedEventImpl(firstProcessDefinition), new CloudProcessDeployedEventImpl(secondProcessDefinition));
    // when
    ResponseEntity<PagedResources<CloudProcessDefinition>> responseEntity = restTemplate.getProcDefinitions();
    // then
    assertThat(responseEntity.getBody()).isNotNull().extracting(ProcessDefinition::getId, ProcessDefinition::getName, ProcessDefinition::getKey).containsExactly(tuple(firstProcessDefinition.getId(), "My First Process", "myFirstProcessKey"), tuple(secondProcessDefinition.getId(), "My second Process", "mySecondProcess"));
}
Also used : CloudProcessDeployedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl) ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) PagedResources(org.springframework.hateoas.PagedResources) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with CloudProcessDeployedEventImpl

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

the class QueryProcessDefinitionIT method shouldUpdateDefinitionOnDuplicate.

@Test
public void shouldUpdateDefinitionOnDuplicate() {
    // given
    ProcessDefinitionImpl initialProcessDefinition = new ProcessDefinitionImpl();
    String processDefinitionId = UUID.randomUUID().toString();
    initialProcessDefinition.setId(processDefinitionId);
    initialProcessDefinition.setKey("myProcessKey");
    initialProcessDefinition.setName("My Process");
    ProcessDefinitionImpl duplicatedProcessDefinition = new ProcessDefinitionImpl();
    // it has the same id as the first one, so it will be considered as duplicate
    duplicatedProcessDefinition.setId(processDefinitionId);
    duplicatedProcessDefinition.setKey("myProcessUpdated");
    duplicatedProcessDefinition.setName("My Process updated");
    duplicatedProcessDefinition.setDescription("Updated description");
    producer.send(new CloudProcessDeployedEventImpl(initialProcessDefinition), new CloudProcessDeployedEventImpl(duplicatedProcessDefinition));
    // when
    ResponseEntity<PagedResources<CloudProcessDefinition>> responseEntity = restTemplate.getProcDefinitions();
    // then
    assertThat(responseEntity.getBody()).isNotNull().extracting(ProcessDefinition::getId, ProcessDefinition::getKey, ProcessDefinition::getName, ProcessDefinition::getDescription).containsExactly(tuple(initialProcessDefinition.getId(), "myProcessUpdated", "My Process updated", "Updated description"));
}
Also used : CloudProcessDeployedEventImpl(org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl) ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) PagedResources(org.springframework.hateoas.PagedResources) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

CloudProcessDeployedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessDeployedEventImpl)18 ProcessDefinitionImpl (org.activiti.api.runtime.model.impl.ProcessDefinitionImpl)13 Test (org.junit.jupiter.api.Test)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 PagedResources (org.springframework.hateoas.PagedResources)6 File (java.io.File)4 ArrayList (java.util.ArrayList)2 CloudRuntimeEvent (org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent)2 CloudBPMNActivityCancelledEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCancelledEventImpl)2 CloudBPMNActivityCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityCompletedEventImpl)2 CloudBPMNActivityStartedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudBPMNActivityStartedEventImpl)2 CloudIntegrationErrorReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationErrorReceivedEventImpl)2 CloudIntegrationRequestedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationRequestedEventImpl)2 CloudIntegrationResultReceivedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudIntegrationResultReceivedEventImpl)2 CloudProcessCancelledEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCancelledEventImpl)2 CloudProcessCompletedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessCompletedEventImpl)2 CloudProcessStartedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessStartedEventImpl)2 CloudProcessSuspendedEventImpl (org.activiti.cloud.api.process.model.impl.events.CloudProcessSuspendedEventImpl)2 CloudTaskAssignedEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskAssignedEventImpl)2 CloudTaskCancelledEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskCancelledEventImpl)2