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);
}
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"));
}
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"));
}
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"));
}
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"));
}
Aggregations