Skip to content

Commit

Permalink
Merge pull request #57 from rgdoliveira/sync_main
Browse files Browse the repository at this point in the history
Sync main branch with Apache main branch
  • Loading branch information
rgdoliveira authored Sep 5, 2024
2 parents b138650 + a1fcb17 commit 42e3f79
Show file tree
Hide file tree
Showing 36 changed files with 889 additions and 754 deletions.
2 changes: 1 addition & 1 deletion addons/common/events/mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion addons/common/monitoring/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion addons/common/tracing/tracing-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion api/kogito-events-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion api/kogito-events-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" id="_PLWQUA_VEDmQT-O0r26GEw" exporter="jBPM Process Modeler" exporterVersion="2.0" targetNamespace="http://www.omg.org/bpmn20">
<bpmn2:itemDefinition id="_VAItem" structureRef="Boolean"/>
<bpmn2:itemDefinition id="_VBItem" structureRef="Boolean"/>
<bpmn2:itemDefinition id="_Task1" structureRef="String"/>
<bpmn2:itemDefinition id="_Task2" structureRef="String"/>
<bpmn2:itemDefinition id="_Task3" structureRef="String"/>
<bpmn2:process id="GatewayFEEL" drools:packageName="org.jbpm.bpmn2.feel" drools:version="1.0" drools:adHoc="false" name="BPMN2-GatewayFEEL" isExecutable="true" processType="Public">
<bpmn2:property id="VA" itemSubjectRef="_VAItem" name="VA"/>
<bpmn2:property id="VB" itemSubjectRef="_VBItem" name="VB"/>
<bpmn2:property id="Task1" itemSubjectRef="_Task1" name="Task1"/>
<bpmn2:property id="Task2" itemSubjectRef="_Task2" name="Task2"/>
<bpmn2:property id="Task3" itemSubjectRef="_Task3" name="Task3"/>

<bpmn2:sequenceFlow id="_E1B7054B-A29B-4004-9358-4D924010200B" sourceRef="_D01D9CA2-D9F4-4761-89AA-E6D8F824F03C" targetRef="_3D4EC1AC-4EDC-43D0-A408-837B0695CB8A"/>
<bpmn2:sequenceFlow id="_66CF5A6C-015A-4BDB-AEA9-4D9F0CAC4B7E" sourceRef="_B0265896-960C-4217-8F36-7F2FF511C0FC" targetRef="_F8B24DAF-040D-4F22-9944-694910B0F3AD"/>
<bpmn2:sequenceFlow id="_F2F5F573-A9B1-4FF8-A331-4980B4D773B8" sourceRef="_D4EDE70E-D26F-4B74-BFBE-1371286E11EE" targetRef="_D01D9CA2-D9F4-4761-89AA-E6D8F824F03C">
Expand Down
62 changes: 48 additions & 14 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,38 @@
import org.jbpm.bpmn2.activity.UserTaskWithSimulationMetaDataProcess;
import org.jbpm.bpmn2.adhoc.SubProcessInAdHocProcessModel;
import org.jbpm.bpmn2.adhoc.SubProcessInAdHocProcessProcess;
import org.jbpm.bpmn2.flow.*;
import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalModel;
import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalProcess;
import org.jbpm.bpmn2.flow.MinimalImplicitModel;
import org.jbpm.bpmn2.flow.MinimalImplicitProcess;
import org.jbpm.bpmn2.flow.MinimalMetadataModel;
import org.jbpm.bpmn2.flow.MinimalMetadataProcess;
import org.jbpm.bpmn2.flow.MinimalModel;
import org.jbpm.bpmn2.flow.MinimalProcess;
import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalModel;
import org.jbpm.bpmn2.flow.MinimalWithDIGraphicalProcess;
import org.jbpm.bpmn2.flow.MinimalWithGraphicalModel;
import org.jbpm.bpmn2.flow.MinimalWithGraphicalProcess;
import org.jbpm.bpmn2.flow.ProcessCustomDescriptionMetaDataModel;
import org.jbpm.bpmn2.flow.ProcessCustomDescriptionMetaDataProcess;
import org.jbpm.bpmn2.flow.ProcessVariableCustomDescriptionMetaDataModel;
import org.jbpm.bpmn2.flow.ProcessVariableCustomDescriptionMetaDataProcess;
import org.jbpm.bpmn2.flow.ProcessWithVariableNameModel;
import org.jbpm.bpmn2.flow.ProcessWithVariableNameProcess;
import org.jbpm.bpmn2.flow.SubProcessModel;
import org.jbpm.bpmn2.flow.SubProcessProcess;
import org.jbpm.bpmn2.flow.UserTaskActorGroupModel;
import org.jbpm.bpmn2.flow.UserTaskActorGroupProcess;
import org.jbpm.bpmn2.flow.UserTaskActorModel;
import org.jbpm.bpmn2.flow.UserTaskActorProcess;
import org.jbpm.bpmn2.flow.UserTaskGroupModel;
import org.jbpm.bpmn2.flow.UserTaskGroupProcess;
import org.jbpm.bpmn2.flow.UserTaskModel;
import org.jbpm.bpmn2.flow.UserTaskNoneModel;
import org.jbpm.bpmn2.flow.UserTaskNoneProcess;
import org.jbpm.bpmn2.flow.UserTaskProcess;
import org.jbpm.bpmn2.flow.XORSameTargetModel;
import org.jbpm.bpmn2.flow.XORSameTargetProcess;
import org.jbpm.bpmn2.handler.ReceiveTaskHandler;
import org.jbpm.bpmn2.handler.SendTaskHandler;
import org.jbpm.bpmn2.objects.Account;
Expand Down Expand Up @@ -218,14 +249,13 @@ public void testMinimalProcessWithDIGraphical() {

@Test
public void testMinimalProcessMetaData() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessMetaData.bpmn2");

Application app = ProcessTestHelper.newApplication();
final List<String> list1 = new ArrayList<>();
final List<String> list2 = new ArrayList<>();
final List<String> list3 = new ArrayList<>();
final List<String> list4 = new ArrayList<>();
kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() {

ProcessTestHelper.registerProcessEventListener(app, new DefaultKogitoProcessEventListener() {
@Override
public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
logger.debug("before node");
Expand Down Expand Up @@ -274,10 +304,14 @@ public void afterProcessStarted(ProcessStartedEvent event) {
}
}
});
Map<String, Object> params = new HashMap<>();
params.put("x", "krisv");
KogitoProcessInstance processInstance = kruntime.startProcess("MinimalMetadata", params);
assertProcessInstanceCompleted(processInstance);

org.kie.kogito.process.Process<MinimalMetadataModel> process = MinimalMetadataProcess.newProcess(app);
MinimalMetadataModel model = process.createModel();
model.setX("krisv");
ProcessInstance<MinimalMetadataModel> processInstance = process.createInstance(model);
processInstance.start();

assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
assertThat(list1).hasSize(3);
assertThat(list2).hasSize(2);
assertThat(list3).hasSize(1);
Expand Down Expand Up @@ -857,10 +891,8 @@ public void testCallActivityByName() throws Exception {

@Test
public void testSubProcess() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-SubProcess.bpmn2");

kruntime.getProcessEventManager().addEventListener(new DefaultKogitoProcessEventListener() {

Application app = ProcessTestHelper.newApplication();
ProcessTestHelper.registerProcessEventListener(app, new DefaultKogitoProcessEventListener() {
@Override
public void afterProcessStarted(ProcessStartedEvent event) {
logger.debug(event.toString());
Expand All @@ -876,8 +908,10 @@ public void afterVariableChanged(ProcessVariableChangedEvent event) {
logger.debug(event.toString());
}
});
KogitoProcessInstance processInstance = kruntime.startProcess("SubProcess");
assertProcessInstanceCompleted(processInstance);
org.kie.kogito.process.Process<SubProcessModel> definition = SubProcessProcess.newProcess(app);
ProcessInstance<SubProcessModel> processInstance = definition.createInstance(definition.createModel());
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}

@Test
Expand Down
76 changes: 48 additions & 28 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/FEELTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,65 @@
*/
package org.jbpm.bpmn2;

import java.util.HashMap;
import java.util.Map;

import org.jbpm.bpmn2.feel.GatewayFEELModel;
import org.jbpm.bpmn2.feel.GatewayFEELProcess;
import org.jbpm.test.utils.EventTrackerProcessListener;
import org.jbpm.test.utils.ProcessTestHelper;
import org.junit.jupiter.api.Test;
import org.kie.kogito.Application;
import org.kie.kogito.process.ProcessInstance;
import org.kie.kogito.process.ProcessInstanceExecutionException;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

public class FEELTest extends JbpmBpmn2TestCase {

@Test
public void testGatewayFEEL() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/feel/BPMN2-GatewayFEEL.bpmn2");

Map<String, Object> params1 = new HashMap<String, Object>();
params1.put("VA", Boolean.TRUE);
params1.put("VB", Boolean.FALSE);
org.jbpm.workflow.instance.WorkflowProcessInstance procInstance1 = (org.jbpm.workflow.instance.WorkflowProcessInstance) kruntime.startProcess("GatewayFEEL", params1);
assertThat(procInstance1.getVariable("Task1")).isEqualTo("ok");
assertThat(procInstance1.getVariable("Task2")).isEqualTo("ok");
assertThat(procInstance1.getVariable("Task3")).isNull();
assertNodeTriggered(procInstance1.getStringId(), "Task2", "VA and not(VB)");

Map<String, Object> params2 = new HashMap<String, Object>();
params2.put("VA", Boolean.FALSE);
params2.put("VB", Boolean.TRUE);
org.jbpm.workflow.instance.WorkflowProcessInstance procInstance2 = (org.jbpm.workflow.instance.WorkflowProcessInstance) kruntime.startProcess("GatewayFEEL", params2);
assertThat(procInstance2.getVariable("Task1")).isEqualTo("ok");
assertThat(procInstance2.getVariable("Task2")).isNull();
assertThat(procInstance2.getVariable("Task3")).isEqualTo("ok");
assertNodeTriggered(procInstance2.getStringId(), "Task3", "VB or not(VA)");
public void testGatewayFEEL() {
Application app = ProcessTestHelper.newApplication();
EventTrackerProcessListener eventTrackerProcessListener = new EventTrackerProcessListener();

ProcessTestHelper.registerProcessEventListener(app, eventTrackerProcessListener);
org.kie.kogito.process.Process<GatewayFEELModel> process = GatewayFEELProcess.newProcess(app);
GatewayFEELModel model = process.createModel();
model.setVA(Boolean.TRUE);
model.setVB(Boolean.FALSE);
ProcessInstance<GatewayFEELModel> procInstance1 = process.createInstance(model);
procInstance1.start();

assertThat(procInstance1.variables().getTask1()).isEqualTo("ok");
assertThat(procInstance1.variables().getTask2()).isEqualTo("ok");
assertThat(procInstance1.variables().getTask3()).isNull();

assertThat(eventTrackerProcessListener.tracked()).anyMatch(ProcessTestHelper.triggered("Task2"))
.anyMatch(ProcessTestHelper.triggered("VA and not(VB)"));

model.setVA(Boolean.FALSE);
model.setVB(Boolean.TRUE);

ProcessInstance<GatewayFEELModel> procInstance2 = process.createInstance(model);
procInstance2.start();

assertThat(procInstance2.variables().getTask1()).isEqualTo("ok");
assertThat(procInstance2.variables().getTask2()).isNull();
assertThat(procInstance2.variables().getTask3()).isEqualTo("ok");
assertThat(eventTrackerProcessListener.tracked()).anyMatch(ProcessTestHelper.triggered("Task3"))
.anyMatch(ProcessTestHelper.triggered("VB or not(VA)"));
}

@Test
public void testGatewayFEELWrong() {
assertThatExceptionOfType(RuntimeException.class)
.isThrownBy(() -> createKogitoProcessRuntime("BPMN2-GatewayFEEL-wrong.bpmn2"))
.withMessageContaining("Invalid FEEL expression: 'VA and Not(VB)'")
.withMessageContaining("Invalid FEEL expression: 'VB or nOt(VA)'");
Application app = ProcessTestHelper.newApplication();
org.kie.kogito.process.Process<GatewayFEELModel> process = GatewayFEELProcess.newProcess(app);
ProcessInstance<GatewayFEELModel> instance = process.createInstance(process.createModel());
instance.start();
assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_ERROR);
assertThat(instance.error().isPresent()).isTrue();
assertThatExceptionOfType(ProcessInstanceExecutionException.class)
.isThrownBy(instance::checkError).withMessageContaining("org.jbpm.process.instance.impl.FeelReturnValueEvaluatorException")
.withMessageContaining("ERROR Unknown variable 'VA'")
.withMessageContaining("ERROR Unknown variable name 'VB'");

}

}
Loading

0 comments on commit 42e3f79

Please sign in to comment.