Skip to content

Commit

Permalink
test coverage for support of expression for message event data mappin…
Browse files Browse the repository at this point in the history
…g, persistence addon discovery and fixed child process in different package
  • Loading branch information
mswiderski committed Jun 1, 2022
1 parent 8d2726d commit d1586a8
Show file tree
Hide file tree
Showing 22 changed files with 202 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ public int compare(Parameter o1, Parameter o2) {
clazz.addImport(subunit.getPackageDeclaration().get().getNameAsString(), false, true);

}

subunit.getImports().stream().filter(imp -> imp.isAsterisk()).forEach(imp -> clazz.addImport(imp));
}

collectSubProcessModels(modelfqcn.substring(modelfqcn.lastIndexOf('.') + 1), template, subprocesses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# key = value
quarkus.automatiko.metrics.enabled=false

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

# allow to pass in user/group query params as authentication info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Configuration file
# key = value
quarkus.automatiko.persistence.type=cassandra
#quarkus.automatiko.persistence.cassandra.create-keyspace=false
#quarkus.automatiko.persistence.cassandra.create-tables=false
quarkus.automatiko.persistence.cassandra.keyspace=automatiko

quarkus.automatiko.jobs.type=cassandra
#quarkus.automatiko.jobs.cassandra.create-keyspace=false
#quarkus.automatiko.jobs.cassandra.create-tables=false
quarkus.automatiko.jobs.cassandra.keyspace=automatiko
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# key = value
quarkus.automatiko.metrics.enabled=false

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

# allow to pass in user/group query params as authentication info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configuration file
# key = value
quarkus.automatiko.metrics.enabled=false
quarkus.automatiko.persistence.type=db

# set remove-at-completion to true if you need to have all data managed by the process to be removed
quarkus.automatiko.persistence.database.remove-at-completion=false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Configuration file
# key = value
quarkus.automatiko.persistence.type=dynamodb
# specific to dynamodb configs
#quarkus.automatiko.persistence.dynamodb.create-tables=false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ mp.openapi.extensions.smallrye.info.title=${project.name}
mp.openapi.extensions.smallrye.info.version=${project.version}
mp.openapi.extensions.smallrye.info.description=${project.description}

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target/processes

%test.mp.messaging.incoming.email-received.connector=smallrye-in-memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# key = value
quarkus.automatiko.metrics.enabled=false

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

# allow to pass in user/group query params as authentication info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ quarkus.automatiko.metrics.enabled=false
# enable following property to keep instances after completion, including files regardless of the storage
#quarkus.automatiko.on-instance-end=keep

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

# enable following property to encrypt data stored (both workflow state and files on file system)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
# key = value
quarkus.automatiko.metrics.enabled=false

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.persistence.encryption=base64

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

# allow to pass in user/group query params as authentication info
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.acme;

import io.automatiko.engine.api.Functions;

public class PersonFunctions implements Functions {

public static Person personRewrite(Person person) {
Person rewritten = new Person();

rewritten.setAge(person.getAge() + 10);
rewritten.setName(person.getName().toUpperCase());
return rewritten;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:automatiko="https://automatiko.io" xmlns="https://automatiko.io" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:java="http://www.java.com/javaTypes" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd https://automatiko.io automatiko.xsd" id="Definition" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="2.0.0" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="https://automatiko.io" typeLanguage="http://www.java.com/javaTypes">
<bpmn2:itemDefinition id="ItemDefinition_11" isCollection="false" structureRef="org.acme.Person"/>
<bpmn2:message id="Message_1" itemRef="ItemDefinition_11" name="sperson">
<bpmn2:extensionElements>
<automatiko:metaData name="HTTPX-TEST">
<automatiko:metaValue><![CDATA["automatiko"]]></automatiko:metaValue>
</automatiko:metaData>
<automatiko:metaData name="connector">
<automatiko:metaValue><![CDATA[http]]></automatiko:metaValue>
</automatiko:metaData>
</bpmn2:extensionElements>
</bpmn2:message>
<bpmn2:process id="sendsexp" automatiko:packageName="org.acme" name="Send to HTTP endpoint using expression" isExecutable="true" processType="Public">
<bpmn2:extensionElements>
<automatiko:import name="org.acme.Person"/>
</bpmn2:extensionElements>
<bpmn2:startEvent id="StartEvent_1" name="StartProcess">
<bpmn2:extensionElements>
<automatiko:metaData name="elementname">
<automatiko:metaValue><![CDATA[StartProcess]]></automatiko:metaValue>
</automatiko:metaData>
</bpmn2:extensionElements>
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:scriptTask id="ScriptTask_1" name="log" scriptFormat="http://www.java.com/java">
<bpmn2:extensionElements>
<automatiko:metaData name="elementname">
<automatiko:metaValue><![CDATA[log]]></automatiko:metaValue>
</automatiko:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
<bpmn2:script>log(&quot;About to send message {}&quot;, person)</bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_1" automatiko:priority="1" sourceRef="StartEvent_1" targetRef="ScriptTask_1"/>
<bpmn2:endEvent id="EndEvent_1" name="send to HTTP">
<bpmn2:extensionElements>
<automatiko:metaData name="elementname">
<automatiko:metaValue><![CDATA[send to HTTP]]></automatiko:metaValue>
</automatiko:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:dataInput id="DataInput_1" itemSubjectRef="ItemDefinition_11" name="Message_1_Input"/>
<bpmn2:dataInputAssociation id="DataInputAssociation_1">
<bpmn2:targetRef>DataInput_1</bpmn2:targetRef>
<bpmn2:assignment id="Assignment_1">
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_3">#{personRewrite(person)}</bpmn2:from>
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_1">DataInput_1</bpmn2:to>
</bpmn2:assignment>
</bpmn2:dataInputAssociation>
<bpmn2:inputSet id="InputSet_1" name="Input Set 1">
<bpmn2:dataInputRefs>DataInput_1</bpmn2:dataInputRefs>
</bpmn2:inputSet>
<bpmn2:messageEventDefinition id="MessageEventDefinition_1" messageRef="Message_1"/>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_2" automatiko:priority="1" sourceRef="ScriptTask_1" targetRef="EndEvent_1"/>
<bpmn2:dataObject id="person" name="person" itemSubjectRef="ItemDefinition_11"/>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="sendsexp">
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="120.0" y="120.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_1">
<dc:Bounds height="11.0" width="52.0" x="112.0" y="156.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_ScriptTask_1" bpmnElement="ScriptTask_1" isExpanded="true">
<dc:Bounds height="50.0" width="110.0" x="261.0" y="113.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_2">
<dc:Bounds height="11.0" width="13.0" x="309.0" y="132.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="460.0" y="120.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_3">
<dc:Bounds height="11.0" width="56.0" x="450.0" y="156.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_DataObject_1" bpmnElement="person">
<dc:Bounds height="50.0" width="36.0" x="240.0" y="230.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_4">
<dc:Bounds height="11.0" width="28.0" x="244.0" y="280.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_ScriptTask_1">
<di:waypoint xsi:type="dc:Point" x="156.0" y="138.0"/>
<di:waypoint xsi:type="dc:Point" x="208.0" y="138.0"/>
<di:waypoint xsi:type="dc:Point" x="261.0" y="138.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_5"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="BPMNShape_ScriptTask_1" targetElement="BPMNShape_EndEvent_1">
<di:waypoint xsi:type="dc:Point" x="371.0" y="138.0"/>
<di:waypoint xsi:type="dc:Point" x="415.0" y="138.0"/>
<di:waypoint xsi:type="dc:Point" x="460.0" y="138.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_6"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_DataInputAssociation_1" bpmnElement="DataInputAssociation_1" sourceElement="BPMNShape_DataObject_1" targetElement="BPMNShape_EndEvent_1">
<di:waypoint xsi:type="dc:Point" x="276.0" y="255.0"/>
<di:waypoint xsi:type="dc:Point" x="478.0" y="255.0"/>
<di:waypoint xsi:type="dc:Point" x="478.0" y="156.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_7"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,79 @@ public void testProcessSendsAndReceives() throws InterruptedException {
.body("$.size()", is(0));
}

@Test
public void testProcessSendsWithExpressionAndReceives() throws InterruptedException {
String id = "bbb";
String addPayload = "{\n"
+ " \"person\": {\n"
+ " \"name\": \"john\",\n"
+ " \"age\": 41\n"
+ " }\n"
+ "}";
given()
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body(addPayload)
.when()
.post("/sendsexp?businessKey=" + id)
.then()
//.log().body(true)
.statusCode(200)
.body("id", notNullValue(), "person.name", equalTo("john"), "person.age", equalTo(41));

given()
.accept(ContentType.JSON)
.when()
.get("/sendsexp")
.then().statusCode(200)
.body("$.size()", is(0));

long elapsed = 3000;

while(elapsed >= 0) {
elapsed -= 1000;
Thread.sleep(1000);
int size = given()
.accept(ContentType.JSON)
.when()
.get("/recivers")
.then().statusCode(200)
.extract().path("$.size()");

if (size == 1) {
break;
}
}

String receiversId = given()
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body(addPayload)
.when()
.get("/recivers")
.then()
//.log().body(true)
.statusCode(200)
.body("[0].id", notNullValue(), "[0].person.name", equalTo("JOHN"), "[0].person.age", equalTo(51))
.extract().path("[0].id");

given()
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body(addPayload)
.when()
.delete("/recivers/"+receiversId)
.then()
//.log().body(true)
.statusCode(200);

given()
.accept(ContentType.JSON)
.when()
.get("/recivers")
.then().statusCode(200)
.body("$.size()", is(0));
}

// @formatter:on
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Configuration file
# key = value
quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target/processes

mp.openapi.extensions.smallrye.info.title=${project.name}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Configuration file
# key = value
quarkus.automatiko.persistence.type=mongodb
quarkus.automatiko.persistence.mongodb.database=automatiko

quarkus.automatiko.jobs.type=mongodb
quarkus.automatiko.jobs.mongodb.database=automatiko

# allow to pass in user/group query params as authentication info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Configuration file
# key = value
quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target/processes

mp.openapi.extensions.smallrye.info.title=${project.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# key = value
quarkus.automatiko.metrics.enabled=false

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target/processes

mp.openapi.extensions.smallrye.info.title=${project.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# key = value
quarkus.automatiko.metrics.enabled=true

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

# allow to pass in user/group query params as authentication info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Configuration file
# key = value

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

quarkus.swagger-ui.theme=newspaper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ quarkus.automatiko.security.authorized-only=false
quarkus.automatiko.persistence.transaction-log.enabled=true
quarkus.automatiko.persistence.transaction-log.folder=target/tlog

quarkus.automatiko.persistence.type=filesystem
quarkus.automatiko.persistence.filesystem.path=target

quarkus.automatiko.jobs.type=filesystem
quarkus.automatiko.jobs.filesystem.path=target/jobs

quarkus.swagger-ui.always-include=true
Loading

0 comments on commit d1586a8

Please sign in to comment.