如果归集任务下面的子项都取消了,归集任务可以直接关闭
This commit is contained in:
1 parent
62f43056e2
commit
c94f0f14d2
7 files changed
+74
-12
No files matched your search
+30
@@ -26,12 +26,14 @@ public class AggregationItemCancellationTest {
|
||||
when(tasks.selectUsdtAggregationTaskByIdForUpdate(10L)).thenReturn(new UsdtAggregationTask());
|
||||
when(items.cancelPendingItem(1L)).thenReturn(1);
|
||||
service.cancelItem(1L, false);
|
||||
verify(tasks).closeIfAllItemsCancelled(10L);
|
||||
when(items.cancelPendingItem(1L)).thenReturn(0);
|
||||
try {
|
||||
service.cancelItem(1L, false);
|
||||
fail("执行中、成功、失败和已取消状态必须拒绝取消");
|
||||
} catch (CustomException expected) {
|
||||
assertTrue(expected.getMessage().contains("仅待执行"));
|
||||
verify(tasks, times(1)).closeIfAllItemsCancelled(10L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +87,34 @@ public class AggregationItemCancellationTest {
|
||||
assertEquals(Boolean.TRUE, execute.invoke(service, snapshot, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void closedTaskCannotBeExecutedOrApproved() {
|
||||
com.ruoyi.system.service.IUsdtAggregationTaskService taskService =
|
||||
mock(com.ruoyi.system.service.IUsdtAggregationTaskService.class);
|
||||
UsdtAggregationTaskMapper tasks = mock(UsdtAggregationTaskMapper.class);
|
||||
com.ruoyi.system.domain.UsdtAggregationTaskPlus task = new com.ruoyi.system.domain.UsdtAggregationTaskPlus();
|
||||
task.setStatus(4);
|
||||
when(taskService.getById(10L)).thenReturn(task);
|
||||
UsdtAggregationWorkflowService workflow = new UsdtAggregationWorkflowService(
|
||||
null, null, taskService, null, null, tasks, null, null, null, null, null);
|
||||
try {
|
||||
workflow.executeTask(10L, null, false);
|
||||
fail("已关闭任务不可执行");
|
||||
} catch (CustomException expected) {
|
||||
assertTrue(expected.getMessage().contains("已关闭"));
|
||||
verify(tasks, never()).startExecutableTask(10L);
|
||||
}
|
||||
UsdtAggregationTask closed = new UsdtAggregationTask();
|
||||
closed.setStatus(4);
|
||||
when(tasks.selectUsdtAggregationTaskByIdForUpdate(10L)).thenReturn(closed);
|
||||
try {
|
||||
workflow.approve(10L, true);
|
||||
fail("已关闭任务不可重新审核");
|
||||
} catch (CustomException expected) {
|
||||
verify(tasks, never()).updateUsdtAggregationTask(closed);
|
||||
}
|
||||
}
|
||||
|
||||
private UsdtAggregationWorkflowService service(UsdtAggregationTaskMapper tasks,
|
||||
UsdtAggregationTaskItemMapper items) {
|
||||
return new UsdtAggregationWorkflowService(null, null, null, null, null,
|
||||
|
||||
Reference in new issue
Block a user