Skip to content

Commit

Permalink
[KOGITO-9763] Add integration test for management addon
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Aug 29, 2023
1 parent 1b49af0 commit 54b8bc5
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@

import com.fasterxml.jackson.databind.JsonNode;

import static org.jbpm.ruleflow.core.Metadata.UNIQUE_ID;

public abstract class BaseProcessInstanceManagementResource<T> implements ProcessInstanceManagement<T> {

private static final String PROCESS_REQUIRED = "Process id must be given";
Expand Down Expand Up @@ -94,7 +92,7 @@ public T doGetProcessNodes(String processId) {
Map<String, Object> data = new HashMap<>();
data.put("id", n.getId());
data.put("uniqueId", ((Node) n).getUniqueId());
data.put("nodeDefinitionId", n.getMetaData().get(UNIQUE_ID));
data.put("metadata", n.getMetaData());
data.put("type", n.getClass().getSimpleName());
data.put("name", n.getName());
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void testDoGetProcessNodes() {
.hasFieldOrPropertyWithValue("id", node.getId())
.hasFieldOrPropertyWithValue("name", node.getName())
.hasFieldOrPropertyWithValue("uniqueId", node.getUniqueId())
.hasFieldOrPropertyWithValue("nodeDefinitionId", NODE_UNIQUE_ID)
.hasFieldOrProperty("metadata")
.hasFieldOrPropertyWithValue("type", node.getClass().getSimpleName());
}

Expand Down
100 changes: 100 additions & 0 deletions quarkus/addons/process-management/integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-process-management-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>kogito-addons-quarkus-process-management-integration-tests</artifactId>
<name>Kogito:: Addons :: Quarkus:: Process Management :: Integration Test</name>
<description>Process Management addon testing Testing</description>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-quarkus-serverless-workflow</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-process-management</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<!-- hack for CI to work -->
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-quarkus-serverless-workflow-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkus.devservices.enabled=false
quarkus.http.test-port=0
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"id": "parallel",
"version": "1.0",
"name": "Welcome to the Parallel dimension",
"description": "Testing parallelism",
"start": "Parallel",
"functions": [
{
"name": "concatA",
"type": "expression",
"operation": ".result|=.+\"A\""
},
{
"name": "concatB",
"type": "expression",
"operation": ".result|=.+\"B\""
},
{
"name": "concatC",
"type": "expression",
"operation": ".result|=.+\"C\""
}
],
"states":[
{
"name":"Parallel",
"type":"parallel",
"branches": [ {"name": "branch1", "actions": [{"name": "action1","functionRef":"concatA"}] }, {"name": "branch2","actions": [{"name": "action2", "functionRef":"concatB"}] },{"name": "branch3","actions": [{"name":"action3","functionRef":"concatC"}] }],
"numCompleted" : ".numCompleted",
"completionType" : "atLeast",
"end": {
"terminate": true
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2023 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kie.kogito.quarkus.workflows;

import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.Test;
import org.kie.kogito.serverless.workflow.SWFConstants;

import io.quarkus.test.junit.QuarkusIntegrationTest;
import io.restassured.common.mapper.TypeRef;
import io.restassured.http.ContentType;

import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;

@QuarkusIntegrationTest
class ManagementFlowIT {

@Test
void testManagementAPI() {
assertThat(given().contentType(ContentType.JSON).accept(ContentType.JSON).get("management/processes/parallel/nodes")
.then().statusCode(200).extract().as(new TypeRef<List<Map<String, Object>>>() {
}).stream().map(m -> (Map<String, Object>) m.get("metadata")).filter(m -> m.containsKey(SWFConstants.STATE_NAME) && m.containsKey(SWFConstants.ACTION_NAME)
&& m.containsKey(SWFConstants.BRANCH_NAME))
.count()).isGreaterThanOrEqualTo(3);
}
}
1 change: 1 addition & 0 deletions quarkus/addons/process-management/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<modules>
<module>deployment</module>
<module>runtime</module>
<module>integration-tests</module>
</modules>

</project>

0 comments on commit 54b8bc5

Please sign in to comment.