This is an automated email from the ASF dual-hosted git repository.

nmirasch pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 74e50a089 KOGITO-9807: Create SW example with data-index persistence 
addon (#1813)
74e50a089 is described below

commit 74e50a089751df501fb9fca9e4fafae633cbe49f
Author: nmirasch <[email protected]>
AuthorDate: Thu Nov 16 09:05:16 2023 +0100

    KOGITO-9807: Create SW example with data-index persistence addon (#1813)
    
    * KOGITO-9807: Create SW example with data-index persistence addon
    
    * simplified the example to show just the persistence addon indexation 
without any event communication
    
    * described detailed greet WF interaction
    
    * Include Apache headers
---
 serverless-workflow-examples/pom.xml               |   1 +
 .../README.md                                      | 196 +++++++++++++++++++++
 .../docker-compose/README.md                       |  40 +++++
 .../docker-compose/docker-compose.yml              |  67 +++++++
 .../docker-compose/sql/init.sql                    |  20 +++
 .../docker-compose/startServices.sh                |  36 ++++
 .../pom.xml                                        | 163 +++++++++++++++++
 .../src/main/resources/application.properties      |  33 ++++
 .../src/main/resources/greet.sw.json               |  65 +++++++
 .../org/kie/kogito/examples/DataIndexRestIT.java   |  78 ++++++++
 .../src/test/resources/application.properties      |   1 +
 11 files changed, 700 insertions(+)

diff --git a/serverless-workflow-examples/pom.xml 
b/serverless-workflow-examples/pom.xml
index 7b605c786..7a623d45c 100644
--- a/serverless-workflow-examples/pom.xml
+++ b/serverless-workflow-examples/pom.xml
@@ -50,6 +50,7 @@
         <module>serverless-workflow-correlation-quarkus</module>
         <module>serverless-workflow-custom-function-knative</module>
         <module>serverless-workflow-custom-type</module>
+        
<module>serverless-workflow-data-index-persistence-addon-quarkus</module>
         <module>serverless-workflow-data-index-quarkus</module>
         <module>serverless-workflow-error-quarkus</module>
         <module>serverless-workflow-events-quarkus</module>
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/README.md
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/README.md
new file mode 100644
index 000000000..36579c6e4
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/README.md
@@ -0,0 +1,196 @@
+# Kogito Serverless Workflow - Data Index persistence addon Example
+
+## Description
+
+This example contains a simple workflow service that demonstrates how to use 
Data Index persistence addon as part of the Kogito runtime. 
+The service is described using JSON format as defined in the 
+[CNCF Serverless Workflow 
specification](https://github.com/serverlessworkflow/specification).
+
+## Infrastructure requirements
+
+### PostgreSQL
+
+This example also requires persistence with a PostgreSQL server.
+
+Optionally and for convenience, a docker-compose [configuration 
file](docker-compose/docker-compose.yml) is
+provided in the path [docker-compose/](docker-compose/), where you can just 
run the command from there:
+
+```sh
+./startServices.sh
+```
+
+The configuration for setting up the connection can be found in 
[applications.properties](src/main/resources/application.properties) file, which
+follows the Quarkus JDBC settings, for more information please check [JDBC 
Configuration 
Reference](https://quarkus.io/guides/datasource#jdbc-configuration).
+
+In this way a container for PostgreSQL will be started on port 5432.
+
+## Installing and Running
+
+### Prerequisites
+ 
+You will need:
+  - Java 11+ installed
+  - Environment variable JAVA_HOME set accordingly
+  - Maven 3.8.6+ installed
+  - Docker and Docker Compose to run the required example infrastructure.
+
+When using native image compilation, you will also need: 
+    - GraalVM 22.2+ installed
+    - Environment variable GRAALVM_HOME set accordingly
+    - GraalVM native image needs as well native-image extension: 
https://www.graalvm.org/reference-manual/native-image/
+    - Note that GraalVM native image compilation typically requires other 
packages (glibc-devel, zlib-devel and gcc) to be installed too, please refer to 
GraalVM installation documentation for more details.
+
+NOTE: Quarkus provides a way of creating a native Linux executable without 
GraalVM installed, leveraging a container runtime such as Docker or Podman. 
More details in  
https://quarkus.io/guides/building-native-image#container-runtime 
+
+### Compile and Run in Local Dev Mode
+
+```sh
+mvn clean package quarkus:dev
+```
+
+NOTE: Data Index graphql UI will be available in 
http://localhost:8180/graphiql/
+
+
+### Start infrastructure services
+
+You should start all the services before you execute any of the **Data Index** 
example. To do that please execute:
+
+```sh
+mvn clean package -P container
+```
+
+For Linux and MacOS:
+
+1. Open a Terminal
+2. Go to docker-compose folder
+3. Run ```docker-compose up```
+
+```bash
+cd docker-compose && ./startServices.sh
+```
+
+TIP: If you get a `permission denied` error while creating the postgresql 
container, consider using SELinux context.
+Update the following line:
+```yaml
+    - ./sql:/docker-entrypoint-initdb.d
+```
+to
+```yaml
+    - ./sql:/docker-entrypoint-initdb.d:Z
+```
+
+Once all services bootstrap, the following ports will be assigned on your 
local machine:
+
+- PostgreSQL: 5432
+- PgAdmin: 8055
+- Data Index service: 8180
+- serverless-workflow-service: 8080
+
+> **_NOTE:_**  This step requires the project to be compiled, please consider 
running a ```mvn clean package -Dcontainer``` command on the project root 
before running the ```docker-compose up``` for the first time or any time you 
modify the project.
+
+Once started you can simply stop all services by executing the 
```docker-compose stop```.
+
+All created containers can be removed by executing the ```docker-compose rm```.
+
+### Submit a request
+
+The service based on the JSON workflow definition can be access by sending a 
request to http://localhost:8080/greet'
+with following content
+
+```json
+{
+  "name": "John",
+  "language": "English"
+}
+```
+
+Complete curl command can be found below:
+
+```sh
+curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' 
-d '{"name": "John", "language": "English"}' http://localhost:8080/greet
+```
+
+Log after curl executed:
+
+```json
+{"id":"541a5363-1667-4f6d-a8b4-1299eba81eac","workflowdata":{"name":"John","language":"English","greeting":"Hello
 from JSON Workflow, "}}
+```
+
+In Quarkus you should see the log message printed:
+
+```text
+Hello from JSON Workflow, John
+```
+
+If you would like to greet the person in Spanish, we need to pass the 
following data on workflow start:
+
+```json
+{
+  "name": "John",
+  "language": "Spanish"
+}
+```
+
+Complete curl command can be found below:
+
+```sh
+curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' 
-d '{"name": "John", "language": "Spanish"}' http://localhost:8080/greet
+```
+
+In Quarkus you should now see the log message printed:
+
+```text
+Saludos desde JSON Workflow, John
+```
+
+Then we can verify that the data has been properly indexed accessing to 
http://localhost:8180/graphiql/ and executing the query:
+
+```text
+{ProcessInstances {
+  id 
+  variables
+}}
+```
+
+getting as a result:
+
+```text
+{
+  "data": {
+    "ProcessInstances": [
+      {
+        "id": "0b95e8a1-b52f-48cf-b7d0-38fa3087d467",
+        "variables": {
+          "workflowdata": {
+            "name": "John",
+            "greeting": "Hello from JSON Workflow, ",
+            "language": "English"
+          }
+        }
+      },
+      {
+        "id": "141f7350-7802-4abc-985c-333caf1068f9",
+        "variables": {
+          "workflowdata": {
+            "name": "John",
+            "greeting": "Saludos desde JSON Workflow, ",
+            "language": "Spanish"
+          }
+        }
+      }
+    ]
+  }
+}
+```
+
+Or by command line, executing the complete curl command can be found below:
+
+```sh
+curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST 
--data '{"query" : "{ProcessInstances {id variables}}" }' 
http://localhost:8180/graphql
+```
+
+getting
+
+```text
+{"data":{"ProcessInstances":[{"id":"0b95e8a1-b52f-48cf-b7d0-38fa3087d467","variables":{"workflowdata":{"name":"John","greeting":"Hello
 from JSON Workflow, 
","language":"English"}}},{"id":"141f7350-7802-4abc-985c-333caf1068f9","variables":{"workflowdata":{"name":"John","greeting":"Saludos
 desde JSON Workflow, ","language":"Spanish"}}}]}}
+```
\ No newline at end of file
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/README.md
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/README.md
new file mode 100644
index 000000000..1f17b4154
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/README.md
@@ -0,0 +1,40 @@
+## Kogito and Infrastructure services
+
+To allow a quick setup of all services required to run this demo, we provide a 
docker compose template that starts the following services:
+- Postgresql
+- PgAdmin
+- Data Index
+
+In order to use it, please ensure you have Docker Compose installed on your 
machine, otherwise follow the instructions available
+in [here](https://docs.docker.com/compose/install/).
+
+### Starting required services
+
+Once all services bootstrap, the following ports will be assigned on your 
local machine:
+- PostgresQL: 5432  
+- PgAdmin: 8055 
+- Data Index: 8180
+
+### Postgresql deployment:
+
+####Start services
+
+./startServices.sh 
+
+#### Stopping and removing volume data
+
+To stop all services, simply run:
+
+docker-compose stop
+
+It is also recomended to remove any of stopped containers by running:
+
+docker-compose rm
+
+NOTE: All the running containers can be stopped running `docker stop  $(docker 
ps -a -q)`
+
+NOTE: All the running containers can be removed running `docker rm  $(docker 
ps -a -q)`
+
+For more details please check the Docker Compose documentation.
+
+    docker-compose --help
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/docker-compose.yml
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/docker-compose.yml
new file mode 100644
index 000000000..56070ccab
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/docker-compose.yml
@@ -0,0 +1,67 @@
+version: '2.1'
+
+services:
+  postgres:
+    container_name: postgres
+    image: postgres:13.4-alpine3.14
+    ports:
+      - "5432:5432"
+    volumes:
+      - ./sql:/docker-entrypoint-initdb.d:Z
+    healthcheck:
+      test: [ "CMD", "pg_isready", "-q", "-d", "kogito", "-U", "kogito-user" ]
+      timeout: 45s
+      interval: 10s
+      retries: 50
+    environment:
+      POSTGRES_USER: postgres
+      POSTGRES_PASSWORD: postgres
+
+  pgadmin-compose:
+    image: dpage/pgadmin4:5.0
+    environment:
+      PGADMIN_DEFAULT_EMAIL: [email protected]
+      PGADMIN_DEFAULT_PASSWORD: pass
+    ports:
+      - 8055:80
+    depends_on:
+      - postgres
+    container_name: pgadmin-container
+
+  data-index:
+    container_name: data-index
+    image: quay.io/kiegroup/kogito-data-index-postgresql:${KOGITO_VERSION}
+    ports:
+      - "8180:8080"
+    depends_on:
+      postgres:
+        condition: service_healthy
+    volumes:
+      - 
./../target/classes/META-INF/resources/persistence/protobuf:/home/kogito/data/protobufs/
+    environment:
+      QUARKUS_DATASOURCE_JDBC_URL: "jdbc:postgresql://postgres:5432/kogito"
+      QUARKUS_DATASOURCE_USERNAME: kogito-user
+      QUARKUS_DATASOURCE_PASSWORD: kogito-pass
+      QUARKUS_HTTP_CORS_ORIGINS: "/.*/"
+      QUARKUS_FLYWAY_MIGRATE_AT_START: "true"
+      QUARKUS_FLYWAY_BASELINE_ON_MIGRATE: "true"
+      QUARKUS_FLYWAY_TABLE: FLYWAY_DATAINDEX_SERVICE
+      QUARKUS_HIBERNATE_ORM_DATABASE_GENERATION: update
+      KOGITO_DATA_INDEX_QUARKUS_PROFILE: "http-events-support"
+
+  serverless-workflow-service:
+    container_name: serverless-workflow-service
+    image: dev.local/${USER}/serverless-workflow-service:1.0-SNAPSHOT
+    ports:
+      - "8080:8080"
+    depends_on:
+      postgres:
+        condition: service_healthy
+    environment:
+      QUARKUS_DATASOURCE_JDBC_URL: "jdbc:postgresql://postgres:5432/kogito"
+      QUARKUS_DATASOURCE_USERNAME: kogito-user
+      QUARKUS_DATASOURCE_PASSWORD: kogito-pass
+      QUARKUS_DATASOURCE_DB_KIND: postgresql
+      KOGITO_SERVICE_URL: http://serverless-workflow-service:8080
+
+
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/sql/init.sql
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/sql/init.sql
new file mode 100755
index 000000000..ee1a94650
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/sql/init.sql
@@ -0,0 +1,20 @@
+CREATE ROLE "kogito-user" WITH
+    LOGIN
+    SUPERUSER
+    INHERIT
+    CREATEDB
+    CREATEROLE
+    NOREPLICATION
+    PASSWORD 'kogito-pass';
+
+CREATE DATABASE kogito
+    WITH
+    OWNER = "kogito-user"
+    ENCODING = 'UTF8'
+    LC_COLLATE = 'en_US.utf8'
+    LC_CTYPE = 'en_US.utf8'
+    TABLESPACE = pg_default
+    CONNECTION LIMIT = -1;
+
+GRANT ALL PRIVILEGES ON DATABASE kogito TO "kogito-user";
+GRANT ALL PRIVILEGES ON DATABASE kogito TO postgres;
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/startServices.sh
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/startServices.sh
new file mode 100755
index 000000000..14f0b33ac
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/docker-compose/startServices.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+echo "Script requires your project to be compiled with the right profile: 
../mvn clean install -DskipTests -Pcontainer"
+
+PROJECT_VERSION=$(cd ../ && mvn help:evaluate -Dexpression=project.version -q 
-DforceStdout)
+
+echo "Project version: ${PROJECT_VERSION}"
+
+if [[ $PROJECT_VERSION == *SNAPSHOT ]];
+then
+  KOGITO_VERSION="latest"
+else
+  KOGITO_VERSION=${PROJECT_VERSION%.*}
+fi
+
+echo "Kogito Image version: ${KOGITO_VERSION}"
+echo "KOGITO_VERSION=${KOGITO_VERSION}" > ".env"
+
+docker-compose -f docker-compose.yml up
\ No newline at end of file
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/pom.xml
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/pom.xml
new file mode 100644
index 000000000..bfde7f534
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/pom.xml
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd"; 
xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.kie.kogito.examples</groupId>
+  
<artifactId>serverless-workflow-data-index-persistence-addon-quarkus</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Kogito Example :: Serverless Workflow Data Index persistence addon :: 
Quarkus</name>
+  <description>Kogito Serverless Workflow Data Index persistence addon Example 
- Quarkus</description>
+  <properties>
+    <quarkus-plugin.version>2.16.10.Final</quarkus-plugin.version>
+    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
+    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
+    <quarkus.platform.version>2.16.10.Final</quarkus.platform.version>
+    <kogito.bom.group-id>org.kie.kogito</kogito.bom.group-id>
+    <kogito.bom.artifact-id>kogito-bom</kogito.bom.artifact-id>
+    <kogito.bom.version>2.0.0-SNAPSHOT</kogito.bom.version>
+    <version.compiler.plugin>3.8.1</version.compiler.plugin>
+    <maven.compiler.release>11</maven.compiler.release>
+    <version.failsafe.plugin>3.0.0-M7</version.failsafe.plugin>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>${quarkus.platform.group-id}</groupId>
+        <artifactId>${quarkus.platform.artifact-id}</artifactId>
+        <version>${quarkus.platform.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>${kogito.bom.group-id}</groupId>
+        <artifactId>${kogito.bom.artifact-id}</artifactId>
+        <version>${kogito.bom.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <dependencies>
+    <dependency>
+      <groupId>org.kie.kogito</groupId>
+      <artifactId>kogito-quarkus-serverless-workflow</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-resteasy</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-resteasy-jackson</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.kie.kogito</groupId>
+      <artifactId>kogito-addons-quarkus-persistence-jdbc</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-agroal</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-jdbc-postgresql</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.kie.kogito</groupId>
+      <artifactId>kogito-addons-quarkus-process-management</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.kie.kogito</groupId>
+      <artifactId>kogito-quarkus-serverless-workflow-devui</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.kie.kogito</groupId>
+      <artifactId>kogito-addons-quarkus-source-files</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-junit5</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-resteasy</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.quarkus</groupId>
+      <artifactId>quarkus-resteasy-jackson</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.kie.kogito</groupId>
+      
<artifactId>kogito-addons-quarkus-data-index-persistence-postgresql</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>io.rest-assured</groupId>
+      <artifactId>rest-assured</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.awaitility</groupId>
+      <artifactId>awaitility</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <finalName>${project.artifactId}</finalName>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>${version.compiler.plugin}</version>
+        <configuration>
+          <release>${maven.compiler.release}</release>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>${quarkus.platform.group-id}</groupId>
+        <artifactId>quarkus-maven-plugin</artifactId>
+        <version>${quarkus-plugin.version}</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>build</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <profiles>
+    <profile>
+      <id>container</id>
+      <activation>
+        <property>
+          <name>container</name>
+        </property>
+      </activation>
+      <properties>
+        <quarkus.profile>container</quarkus.profile>
+      </properties>
+      <dependencies>
+        <dependency>
+          <groupId>io.quarkus</groupId>
+          <artifactId>quarkus-container-image-jib</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>native</id>
+      <activation>
+        <property>
+          <name>native</name>
+        </property>
+      </activation>
+      <properties>
+        <quarkus.package.type>native</quarkus.package.type>
+      </properties>
+    </profile>
+  </profiles>
+</project>
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/main/resources/application.properties
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/main/resources/application.properties
new file mode 100644
index 000000000..a35fb1cfe
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/main/resources/application.properties
@@ -0,0 +1,33 @@
+quarkus.kogito.data-index.graphql.ui.always-include=true
+quarkus.swagger-ui.always-include=true
+quarkus.http.test-port=0
+
+kogito.persistence.type=jdbc
+kogito.persistence.proto.marshaller=false
+quarkus.datasource.db-kind=postgresql
+#run create tables scripts
+%container.quarkus.datasource.username=postgres
+%container.quarkus.datasource.password=postgres
+%container.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/kogito
+
+quarkus.flyway.migrate-at-start=true
+quarkus.flyway.baseline-on-migrate=true
+quarkus.hibernate-orm.database.generation=update
+
+kogito.service.url=http://localhost:8080
+
+#quarkus.kubernetes-client.devservices.enabled=false
+quarkus.native.native-image-xmx=8g
+
+# profile to pack this example into a container, to use it execute activate 
the maven container profile, -Dcontainer
+%container.quarkus.container-image.build=true
+%container.quarkus.container-image.push=false
+%container.quarkus.container-image.group=${USER}
+%container.quarkus.container-image.registry=dev.local
+%container.quarkus.container-image.tag=1.0-SNAPSHOT
+%container.quarkus.jib.jvm-entrypoint=/home/kogito/kogito-app-launch.sh
+%container.quarkus.jib.base-jvm-image=quay.io/kiegroup/kogito-runtime-jvm:latest
+%container.quarkus.jib.working-directory=/home/kogito/bin
+%container.quarkus.container-image.name=serverless-workflow-service
+
+
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/main/resources/greet.sw.json
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/main/resources/greet.sw.json
new file mode 100644
index 000000000..967561a2e
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/main/resources/greet.sw.json
@@ -0,0 +1,65 @@
+{
+  "id": "greet",
+  "version": "1.0",
+  "name": "Greeting workflow",
+  "description": "JSON based greeting workflow",
+  "start": "ChooseOnLanguage",
+  "functions": [
+    {
+      "name": "greetFunction",
+      "type": "custom",
+      "operation": "sysout"
+    }
+  ],
+  "states": [
+    {
+      "name": "ChooseOnLanguage",
+      "type": "switch",
+      "dataConditions": [
+        {
+          "condition": "${ .language == \"English\" }",
+          "transition": "GreetInEnglish"
+        },
+        {
+          "condition": "${ .language == \"Spanish\" }",
+          "transition": "GreetInSpanish"
+        }
+      ],
+      "defaultCondition": {
+        "transition": "GreetInEnglish"
+      }
+    },
+    {
+      "name": "GreetInEnglish",
+      "type": "inject",
+      "data": {
+        "greeting": "Hello from JSON Workflow, "
+      },
+      "transition": "GreetPerson"
+    },
+    {
+      "name": "GreetInSpanish",
+      "type": "inject",
+      "data": {
+        "greeting": "Saludos desde JSON Workflow, "
+      },
+      "transition": "GreetPerson"
+    },
+    {
+      "name": "GreetPerson",
+      "type": "operation",
+      "actions": [
+        {
+          "name": "greetAction",
+          "functionRef": {
+            "refName": "greetFunction",
+            "arguments": {
+              "message": ".greeting+.name"
+            }
+          }
+        }
+      ],
+      "end": true
+    }
+  ]
+}
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/test/java/org/kie/kogito/examples/DataIndexRestIT.java
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/test/java/org/kie/kogito/examples/DataIndexRestIT.java
new file mode 100644
index 000000000..784f4f8cf
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/test/java/org/kie/kogito/examples/DataIndexRestIT.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.examples;
+
+import org.junit.jupiter.api.Test;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+
+@QuarkusIntegrationTest
+class DataIndexRestIT {
+
+    static {
+        RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
+    }
+
+    @Test
+    void testDataIndexRest() {
+        given().contentType(ContentType.JSON).body("{ \"query\" : 
\"{ProcessInstances{ id } }\" }")
+                .when().post("/graphql")
+                .then().statusCode(200)
+                .body("data.ProcessInstances.size()", 
is(greaterThanOrEqualTo(0)));
+
+        String processInstanceId = given()
+                .contentType(ContentType.JSON)
+                .accept(ContentType.JSON)
+                .post("/callback")
+                .then()
+                .statusCode(201)
+                .extract()
+                .path("id");
+
+        await()
+                .atLeast(1, SECONDS)
+                .atMost(30, SECONDS)
+                .with().pollInterval(1, SECONDS)
+                .untilAsserted(() -> given()
+                        .contentType(ContentType.JSON)
+                        .accept(ContentType.JSON)
+                        .get("/callback/{id}", processInstanceId)
+                        .then()
+                        .statusCode(404));
+
+        await()
+                .atLeast(1, SECONDS)
+                .atMost(30, SECONDS)
+                .with().pollInterval(1, SECONDS)
+                .untilAsserted(() -> 
given().contentType(ContentType.JSON).body("{ \"query\" : \"{ 
ProcessInstances(where: { id: {equal: \\\"" + processInstanceId + "\\\"}}) { 
id, state } }\" }")
+                        .when().post("/graphql")
+                        .then().statusCode(200)
+                        .body("data.ProcessInstances.size()", is(1))
+                        .body("data.ProcessInstances[0].id", 
is(processInstanceId))
+                        .body("data.ProcessInstances[0].state", 
is("COMPLETED")));
+    }
+}
diff --git 
a/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/test/resources/application.properties
 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/test/resources/application.properties
new file mode 100644
index 000000000..1ed004b3e
--- /dev/null
+++ 
b/serverless-workflow-examples/serverless-workflow-data-index-persistence-addon-quarkus/src/test/resources/application.properties
@@ -0,0 +1 @@
+quarkus.kogito.devservices.enabled=false
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to