Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Jun 17, 2024
1 parent 4234e8f commit 41e9845
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@

import org.kie.api.event.process.ProcessNodeLeftEvent;

public class NodeLeftCountDownProcessEventListener extends NodeCountDownProcessEventListener {
public class NodeLeftCountDownProcessEventListener extends DefaultCountDownProcessEventListener {

private boolean reactOnBeforeNodeLeft = false;
private String nodeName;

public NodeLeftCountDownProcessEventListener() {

}

public NodeLeftCountDownProcessEventListener(String nodeName, int threads) {
super(nodeName, threads);
}

public NodeLeftCountDownProcessEventListener(String nodeName, int threads, boolean reactOnBeforeNodeLeft) {
super(nodeName, threads);
this.reactOnBeforeNodeLeft = reactOnBeforeNodeLeft;
super(threads);
this.nodeName = nodeName;
}

@Override
Expand All @@ -43,11 +39,4 @@ public void afterNodeLeft(ProcessNodeLeftEvent event) {
countDown();
}
}

@Override
public void beforeNodeLeft(ProcessNodeLeftEvent event) {
if (reactOnBeforeNodeLeft && nodeName.equals(event.getNodeInstance().getNodeName())) {
countDown();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,26 @@
*/
package org.jbpm.test.util;

import java.util.concurrent.CountDownLatch;

import org.kie.api.event.process.ProcessNodeTriggeredEvent;

public class NodeCountDownProcessEventListener extends DefaultCountDownProcessEventListener {
public class NodeTriggeredProcessEventListener extends DefaultCountDownProcessEventListener {

protected String nodeName;

public NodeCountDownProcessEventListener() {
public NodeTriggeredProcessEventListener() {

}

@Override
public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
public void afterNodeTriggered(ProcessNodeTriggeredEvent event) {
if (nodeName.equals(event.getNodeInstance().getNodeName())) {
countDown();
}
}

public NodeCountDownProcessEventListener(String nodeName, int threads) {
public NodeTriggeredProcessEventListener(String nodeName, int threads) {
super(threads);
this.nodeName = nodeName;
}

public void reset(String nodeName, int threads) {
this.nodeName = nodeName;
this.latch = new CountDownLatch(threads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener;
import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler;
import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler;
import org.jbpm.test.util.NodeCountDownProcessEventListener;
import org.jbpm.test.util.NodeLeftCountDownProcessEventListener;
import org.jbpm.test.util.ProcessCompletedCountDownProcessEventListener;
import org.jbpm.test.utils.ProcessTestHelper;
Expand Down Expand Up @@ -113,7 +112,7 @@ public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
@Test
public void testBoundaryTimerCycleISO() {
Application app = ProcessTestHelper.newApplication();
NodeCountDownProcessEventListener listener = new NodeCountDownProcessEventListener("Send Update", 3);
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Send Update", 3);
ProcessTestHelper.registerProcessEventListener(app, listener);
org.kie.kogito.process.Process<BoundaryTimerCycleISOModel> definition = BoundaryTimerCycleISOProcess.newProcess(app);
org.kie.kogito.process.ProcessInstance<BoundaryTimerCycleISOModel> instance = definition.createInstance(definition.createModel());
Expand All @@ -126,7 +125,7 @@ public void testBoundaryTimerCycleISO() {
@Test
public void testBoundaryTimerCycleISOVariable() {
Application app = ProcessTestHelper.newApplication();
NodeCountDownProcessEventListener listener = new NodeCountDownProcessEventListener("Send Update", 3);
NodeLeftCountDownProcessEventListener listener = new NodeLeftCountDownProcessEventListener("Send Update", 3);
ProcessTestHelper.registerProcessEventListener(app, listener);
org.kie.kogito.process.Process<BoundaryTimerCycleISOVariableModel> definition = BoundaryTimerCycleISOVariableProcess.newProcess(app);
BoundaryTimerCycleISOVariableModel model = definition.createModel();
Expand Down

0 comments on commit 41e9845

Please sign in to comment.