增加工作流实例实现
This commit is contained in:
parent
ff7544a127
commit
4ac57479a4
@ -91,6 +91,7 @@ class DefaultWorkflowEngineTest {
|
||||
when(workflowDefinitionRepository.findByCodeAndDeletedFalse(workflowCode)).thenReturn(definition);
|
||||
when(workflowInstanceRepository.save(any())).thenAnswer(i -> i.getArgument(0));
|
||||
when(nodeInstanceRepository.save(any())).thenReturn(startNode);
|
||||
when(nodeInstanceRepository.findById(startNode.getId())).thenReturn(Optional.of(startNode));
|
||||
doNothing().when(startNodeExecutor).execute(any(), any());
|
||||
|
||||
// 执行测试
|
||||
@ -119,7 +120,7 @@ class DefaultWorkflowEngineTest {
|
||||
// 执行测试并验证异常
|
||||
WorkflowEngineException exception = assertThrows(WorkflowEngineException.class,
|
||||
() -> workflowEngine.startWorkflow(workflowCode, "test", null));
|
||||
assertEquals(ResponseCode.WORKFLOW_NOT_FOUND.name(), exception.getMessage());
|
||||
assertTrue(exception.getMessage().contains(ResponseCode.WORKFLOW_NOT_FOUND.name()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -136,7 +137,7 @@ class DefaultWorkflowEngineTest {
|
||||
// 执行测试并验证异常
|
||||
WorkflowEngineException exception = assertThrows(WorkflowEngineException.class,
|
||||
() -> workflowEngine.startWorkflow(workflowCode, "test", null));
|
||||
assertEquals(ResponseCode.WORKFLOW_NOT_PUBLISHED.name(), exception.getMessage());
|
||||
assertTrue(exception.getMessage().contains(ResponseCode.WORKFLOW_NOT_PUBLISHED.name()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -179,7 +180,7 @@ class DefaultWorkflowEngineTest {
|
||||
// 执行测试并验证异常
|
||||
WorkflowEngineException exception = assertThrows(WorkflowEngineException.class,
|
||||
() -> workflowEngine.executeNode(nodeInstanceId));
|
||||
assertEquals(ResponseCode.WORKFLOW_NODE_NOT_FOUND.name(), exception.getMessage());
|
||||
assertTrue(exception.getMessage().contains(ResponseCode.WORKFLOW_NODE_NOT_FOUND.name()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -200,7 +201,7 @@ class DefaultWorkflowEngineTest {
|
||||
// 执行测试并验证异常
|
||||
WorkflowEngineException exception = assertThrows(WorkflowEngineException.class,
|
||||
() -> workflowEngine.executeNode(nodeInstanceId));
|
||||
assertEquals(ResponseCode.WORKFLOW_INSTANCE_NOT_RUNNING.name(), exception.getMessage());
|
||||
assertTrue(exception.getMessage().contains(ResponseCode.WORKFLOW_INSTANCE_NOT_RUNNING.name()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -280,11 +281,14 @@ class DefaultWorkflowEngineTest {
|
||||
NodeInstance pausedNode = new NodeInstance();
|
||||
pausedNode.setId(2L);
|
||||
pausedNode.setStatus(NodeStatusEnum.PAUSED);
|
||||
pausedNode.setWorkflowInstance(instance);
|
||||
|
||||
// 配置Mock行为
|
||||
when(workflowInstanceRepository.findById(instanceId)).thenReturn(Optional.of(instance));
|
||||
when(nodeInstanceRepository.findByWorkflowInstanceIdAndStatus(instanceId, NodeStatusEnum.PAUSED))
|
||||
.thenReturn(Arrays.asList(pausedNode));
|
||||
when(nodeInstanceRepository.findById(pausedNode.getId())).thenReturn(Optional.of(pausedNode));
|
||||
doNothing().when(taskNodeExecutor).execute(any(), any());
|
||||
|
||||
// 执行测试
|
||||
workflowEngine.resumeWorkflow(instanceId);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user