Skip to content

Commit

Permalink
[incubator-kie-issues-1131] v7 migration to code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhitocode committed Aug 29, 2024
1 parent 4cd44dc commit a7ab0bb
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerCycle3Process;
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerCycleCronModel;
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerCycleCronProcess;
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerCycleWithErrorModel;
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerCycleWithErrorProcess;
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerDurationWithErrorModel;
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerDurationWithErrorProcess;
import org.jbpm.bpmn2.intermediate.IntermediateCatchEventTimerDurationWithErrorProcessInstance;
Expand Down Expand Up @@ -1373,29 +1375,24 @@ public void testIntermediateCatchEventConditionFilterByProcessInstance() throws

@Test
@RequirePersistence(false)
public void testIntermediateCatchEventTimerCycleWithError() throws Exception {
public void testIntermediateCatchEventTimerCycleWithError() {
Application app = ProcessTestHelper.newApplication();
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3);

kruntime = createKogitoProcessRuntime(
"org/jbpm/bpmn2/intermediate/BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
kruntime.getProcessEventManager().addEventListener(countDownListener);
Map<String, Object> params = new HashMap<>();
params.put("x", 0);
KogitoProcessInstance processInstance = kruntime.startProcess("IntermediateCatchEventTimerCycleWithError",
params);
assertProcessInstanceActive(processInstance);
// now wait for 1 second for timer to trigger
ProcessTestHelper.registerProcessEventListener(app, countDownListener);
ProcessTestHelper.registerHandler(app, "Human Task", new DoNothingWorkItemHandler());
org.kie.kogito.process.Process<IntermediateCatchEventTimerCycleWithErrorModel> definition = IntermediateCatchEventTimerCycleWithErrorProcess.newProcess(app);
IntermediateCatchEventTimerCycleWithErrorModel model = definition.createModel();
model.setX(0);
ProcessInstance<IntermediateCatchEventTimerCycleWithErrorModel> processInstance = definition.createInstance(model);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
countDownListener.waitTillCompleted();
assertProcessInstanceActive(processInstance);

processInstance = kruntime.getProcessInstance(processInstance.getStringId());
Integer xValue = (Integer) ((KogitoWorkflowProcessInstance) processInstance).getVariable("x");
assertThat(xValue).isEqualTo(3);

kruntime.abortProcessInstance(processInstance.getStringId());
assertProcessInstanceFinished(processInstance, kruntime);

assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
model = processInstance.variables();
Integer xValue = model.getX();
assertThat(xValue).isGreaterThanOrEqualTo(2);
processInstance.abort();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}

@Test
Expand Down
Loading

0 comments on commit a7ab0bb

Please sign in to comment.