优化监听器
This commit is contained in:
@@ -199,4 +199,25 @@ public abstract class TestFlowableManager {
|
||||
manager.approve(instanceId, MapHelper.of("role", "admin"));
|
||||
Assertions.assertEquals(FlowableInstance.Status.COMPLETED, manager.getInstance(instanceId).getStatus());
|
||||
}
|
||||
|
||||
protected abstract Class<? extends FlowableListener> getListenerClass();
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testListener() {
|
||||
FlowableManager manager = flowableManager();
|
||||
FlowableNode node = FlowableNode.builder()
|
||||
.nodeId("1c81366f-4102-4a9e-abb2-1dbcb09062e9")
|
||||
.name("1c81366f-4102-4a9e-abb2-1dbcb09062e9")
|
||||
.description("1c81366f-4102-4a9e-abb2-1dbcb09062e9")
|
||||
.type(FlowableNode.Type.MANUAL)
|
||||
.listeners(ListHelper.of(
|
||||
getListenerClass().getName()
|
||||
))
|
||||
.build();
|
||||
manager.create(node);
|
||||
String instanceId = manager.start(node.getNodeId());
|
||||
manager.approve(instanceId);
|
||||
Assertions.assertEquals(FlowableInstance.Status.COMPLETED, manager.getInstance(instanceId).getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.lanyuanxiaoyao.flowable.test;
|
||||
|
||||
import com.lanyuanxiaoyao.flowable.core.model.FlowableAction;
|
||||
import com.lanyuanxiaoyao.flowable.core.model.FlowableInstance;
|
||||
import com.lanyuanxiaoyao.flowable.core.model.FlowableListener;
|
||||
import com.lanyuanxiaoyao.flowable.core.model.FlowableNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250106
|
||||
*/
|
||||
@Slf4j
|
||||
public class SimpleListener implements FlowableListener {
|
||||
@Override
|
||||
public void onFlowStart(FlowableInstance instance, FlowableNode node) {
|
||||
log.info("onFlowStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlowEnd(FlowableInstance instance, FlowableNode node) {
|
||||
log.info("onFlowEnd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionStart(FlowableInstance instance, FlowableNode node) {
|
||||
log.info("onActionStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAction(FlowableInstance instance, FlowableAction action) {
|
||||
log.info("onAction");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionComplete(FlowableInstance instance, FlowableNode node) {
|
||||
log.info("onActionComplete");
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.lanyuanxiaoyao.flowable.test;
|
||||
|
||||
import com.lanyuanxiaoyao.flowable.core.manager.FlowableManager;
|
||||
import com.lanyuanxiaoyao.flowable.core.model.FlowableHandler;
|
||||
import com.lanyuanxiaoyao.flowable.core.model.FlowableListener;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
@@ -14,7 +15,12 @@ public class TestSimpleFlowableManager extends TestFlowableManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends FlowableHandler> getAutomaticNodeClass() {
|
||||
protected Class<? extends FlowableHandler> getHandler() {
|
||||
return SimpleAutoHandler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends FlowableListener> getListenerClass() {
|
||||
return SimpleListener.class;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user