|
@@ -0,0 +1,413 @@
|
|
|
|
|
+package com.enagic.modules.enagic.service;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.dan.modules.message.service.MemberMessageService;
|
|
|
|
|
+import com.enagic.modules.enagic.entity.dos.*;
|
|
|
|
|
+import com.enagic.modules.enagic.mapper.*;
|
|
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
|
|
+import org.junit.jupiter.api.DisplayName;
|
|
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
|
+import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
|
+import org.mockito.InjectMocks;
|
|
|
|
|
+import org.mockito.Mock;
|
|
|
|
|
+import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+
|
|
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
+import static org.mockito.ArgumentMatchers.any;
|
|
|
|
|
+import static org.mockito.Mockito.*;
|
|
|
|
|
+
|
|
|
|
|
+@ExtendWith(MockitoExtension.class)
|
|
|
|
|
+@DisplayName("运维计划服务测试")
|
|
|
|
|
+class OperationPlanServiceTest {
|
|
|
|
|
+
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private OperationPlanMapper operationPlanMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private OperationFlowMapper operationFlowMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private OperationRecordMapper operationRecordMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private HealthAdvisorMapper healthAdvisorMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private MemberTransferMapper memberTransferMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Mock
|
|
|
|
|
+ private MemberMessageService memberMessageService;
|
|
|
|
|
+
|
|
|
|
|
+ @InjectMocks
|
|
|
|
|
+ private OperationPlanService operationPlanService;
|
|
|
|
|
+
|
|
|
|
|
+ private OperationFlow testFlow;
|
|
|
|
|
+ private OperationPlan testPlan;
|
|
|
|
|
+ private HealthAdvisor testAdvisor;
|
|
|
|
|
+
|
|
|
|
|
+ @BeforeEach
|
|
|
|
|
+ void setUp() {
|
|
|
|
|
+ JSONObject node1 = new JSONObject().set("day", 1).set("name", "发货提醒")
|
|
|
|
|
+ .set("content", "您的订单已发货").set("remindType", "WECHAT_MSG");
|
|
|
|
|
+ JSONObject node2 = new JSONObject().set("day", 7).set("name", "使用指导")
|
|
|
|
|
+ .set("content", "开始使用产品").set("remindType", "AI_REMINDER");
|
|
|
|
|
+ JSONArray nodes = new JSONArray().set(node1).set(node2);
|
|
|
|
|
+
|
|
|
|
|
+ testFlow = new OperationFlow();
|
|
|
|
|
+ testFlow.setId(1L);
|
|
|
|
|
+ testFlow.setFlowName("产品A运维流程");
|
|
|
|
|
+ testFlow.setProductId(100L);
|
|
|
|
|
+ testFlow.setNodes(nodes.toString());
|
|
|
|
|
+ testFlow.setStatus("OPEN");
|
|
|
|
|
+
|
|
|
|
|
+ testPlan = new OperationPlan();
|
|
|
|
|
+ testPlan.setId(1L);
|
|
|
|
|
+ testPlan.setFlowId(1L);
|
|
|
|
|
+ testPlan.setMemberId(1L);
|
|
|
|
|
+ testPlan.setMemberName("张三");
|
|
|
|
|
+ testPlan.setProductId(100L);
|
|
|
|
|
+ testPlan.setOrderSn("ORDER123");
|
|
|
|
|
+ testPlan.setCurrentNodeIndex(0);
|
|
|
|
|
+ testPlan.setCurrentNodeName("发货提醒");
|
|
|
|
|
+ testPlan.setStatus("IN_PROGRESS");
|
|
|
|
|
+ testPlan.setSkipCount(0);
|
|
|
|
|
+
|
|
|
|
|
+ testAdvisor = new HealthAdvisor();
|
|
|
|
|
+ testAdvisor.setId(1L);
|
|
|
|
|
+ testAdvisor.setMemberId(1L);
|
|
|
|
|
+ testAdvisor.setMemberName("健康布施者");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("创建运维计划-成功")
|
|
|
|
|
+ void createPlan_WhenSuccess_ShouldCreatePlan() {
|
|
|
|
|
+ when(operationFlowMapper.selectById(1L)).thenReturn(testFlow);
|
|
|
|
|
+ doNothing().when(operationPlanMapper).insert(any(OperationPlan.class));
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.createPlan(1L, 1L, 100L, "ORDER123");
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationPlanMapper).insert(argThat(plan -> {
|
|
|
|
|
+ assertEquals(1L, plan.getFlowId());
|
|
|
|
|
+ assertEquals(1L, plan.getMemberId());
|
|
|
|
|
+ assertEquals(100L, plan.getProductId());
|
|
|
|
|
+ assertEquals("ORDER123", plan.getOrderSn());
|
|
|
|
|
+ assertEquals(0, plan.getCurrentNodeIndex());
|
|
|
|
|
+ assertEquals("发货提醒", plan.getCurrentNodeName());
|
|
|
|
|
+ assertEquals("IN_PROGRESS", plan.getStatus());
|
|
|
|
|
+ assertEquals(0, plan.getSkipCount());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("创建运维计划-流程不存在")
|
|
|
|
|
+ void createPlan_WhenFlowNotFound_ShouldReturn() {
|
|
|
|
|
+ when(operationFlowMapper.selectById(999L)).thenReturn(null);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.createPlan(999L, 1L, 100L, "ORDER123");
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationPlanMapper, never()).insert(any(OperationPlan.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("创建运维计划-流程已关闭")
|
|
|
|
|
+ void createPlan_WhenFlowClosed_ShouldReturn() {
|
|
|
|
|
+ testFlow.setStatus("CLOSE");
|
|
|
|
|
+ when(operationFlowMapper.selectById(1L)).thenReturn(testFlow);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.createPlan(1L, 1L, 100L, "ORDER123");
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationPlanMapper, never()).insert(any(OperationPlan.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("创建运维计划-流程节点为空")
|
|
|
|
|
+ void createPlan_WhenNodesEmpty_ShouldReturn() {
|
|
|
|
|
+ testFlow.setNodes("[]");
|
|
|
|
|
+ when(operationFlowMapper.selectById(1L)).thenReturn(testFlow);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.createPlan(1L, 1L, 100L, "ORDER123");
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationPlanMapper, never()).insert(any(OperationPlan.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("转移至平台-成功创建移交记录")
|
|
|
|
|
+ void transferToPlatform_WhenSuccess_ShouldCreateTransferRecord() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(1L)).thenReturn(testPlan);
|
|
|
|
|
+ when(healthAdvisorMapper.selectOne(any(LambdaQueryWrapper.class))).thenReturn(testAdvisor);
|
|
|
|
|
+ doNothing().when(memberTransferMapper).insert(any(MemberTransfer.class));
|
|
|
|
|
+ doNothing().when(operationPlanMapper).updateById(any(OperationPlan.class));
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.transferToPlatform(1L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(memberTransferMapper).insert(argThat(transfer -> {
|
|
|
|
|
+ assertEquals(1L, transfer.getMemberId());
|
|
|
|
|
+ assertEquals(1L, transfer.getOriginalAdvisorId());
|
|
|
|
|
+ assertEquals("健康布施者", transfer.getOriginalAdvisorName());
|
|
|
|
|
+ assertEquals(0L, transfer.getNewAdvisorId());
|
|
|
|
|
+ assertEquals("平台客服", transfer.getNewAdvisorName());
|
|
|
|
|
+ assertEquals("连续3次未提供运维服务,自动转移", transfer.getTransferReason());
|
|
|
|
|
+ assertEquals("AUTO", transfer.getTriggerType());
|
|
|
|
|
+ assertEquals("COMPLETED", transfer.getStatus());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationPlanMapper).updateById(argThat(plan ->
|
|
|
|
|
+ "TRANSFERRED".equals(plan.getStatus())
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("转移至平台-计划不存在")
|
|
|
|
|
+ void transferToPlatform_WhenPlanNotFound_ShouldReturn() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(999L)).thenReturn(null);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.transferToPlatform(999L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(memberTransferMapper, never()).insert(any(MemberTransfer.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("转移至平台-无原始健康布施者")
|
|
|
|
|
+ void transferToPlatform_WhenNoAdvisor_ShouldStillTransfer() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(1L)).thenReturn(testPlan);
|
|
|
|
|
+ when(healthAdvisorMapper.selectOne(any(LambdaQueryWrapper.class))).thenReturn(null);
|
|
|
|
|
+ doNothing().when(memberTransferMapper).insert(any(MemberTransfer.class));
|
|
|
|
|
+ doNothing().when(operationPlanMapper).updateById(any(OperationPlan.class));
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.transferToPlatform(1L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(memberTransferMapper).insert(argThat(transfer ->
|
|
|
|
|
+ transfer.getOriginalAdvisorId() == null
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("分页查询运维计划-带状态和名称过滤")
|
|
|
|
|
+ void pagePlan_WithFilters_ShouldFilter() {
|
|
|
|
|
+ when(operationPlanMapper.selectPage(any(Page.class), any(LambdaQueryWrapper.class)))
|
|
|
|
|
+ .thenReturn(new Page<>(1, 10));
|
|
|
|
|
+
|
|
|
|
|
+ var result = operationPlanService.pagePlan("IN_PROGRESS", "张三", 1, 10);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ verify(operationPlanMapper).selectPage(any(Page.class), any(LambdaQueryWrapper.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("分页查询运维计划-无过滤条件")
|
|
|
|
|
+ void pagePlan_WithNoFilters_ShouldReturnAll() {
|
|
|
|
|
+ when(operationPlanMapper.selectPage(any(Page.class), any(LambdaQueryWrapper.class)))
|
|
|
|
|
+ .thenReturn(new Page<>(1, 10));
|
|
|
|
|
+
|
|
|
|
|
+ var result = operationPlanService.pagePlan(null, null, 1, 10);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("获取运维计划详情-存在")
|
|
|
|
|
+ void getPlanById_WhenExists_ShouldReturn() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(1L)).thenReturn(testPlan);
|
|
|
|
|
+
|
|
|
|
|
+ OperationPlan result = operationPlanService.getPlanById(1L);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ assertEquals("ORDER123", result.getOrderSn());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("获取运维计划详情-不存在")
|
|
|
|
|
+ void getPlanById_WhenNotExists_ShouldReturnNull() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(999L)).thenReturn(null);
|
|
|
|
|
+
|
|
|
|
|
+ OperationPlan result = operationPlanService.getPlanById(999L);
|
|
|
|
|
+
|
|
|
|
|
+ assertNull(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("手动触发提醒-成功")
|
|
|
|
|
+ void remindPlan_WhenSuccess_ShouldSendMessageAndLog() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(1L)).thenReturn(testPlan);
|
|
|
|
|
+ doNothing().when(memberMessageService).saveMemberMessage(anyLong(), anyString(), anyString(), anyString());
|
|
|
|
|
+ doNothing().when(operationRecordMapper).insert(any(OperationRecord.class));
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.remindPlan(1L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(memberMessageService).saveMemberMessage(
|
|
|
|
|
+ eq(1L),
|
|
|
|
|
+ eq("运维提醒"),
|
|
|
|
|
+ eq("发货提醒"),
|
|
|
|
|
+ eq("您的专属健康布施者为您发送了一条运维提醒")
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationRecordMapper).insert(argThat(record -> {
|
|
|
|
|
+ assertEquals(1L, record.getPlanId());
|
|
|
|
|
+ assertEquals("发货提醒", record.getNodeName());
|
|
|
|
|
+ assertEquals("手动触发提醒", record.getContent());
|
|
|
|
|
+ assertEquals("已发送", record.getResult());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("手动触发提醒-计划不存在")
|
|
|
|
|
+ void remindPlan_WhenPlanNotFound_ShouldReturn() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(999L)).thenReturn(null);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.remindPlan(999L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(memberMessageService, never()).saveMemberMessage(any(), any(), any(), any());
|
|
|
|
|
+ verify(operationRecordMapper, never()).insert(any(OperationRecord.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("手动触发提醒-计划已完成不处理")
|
|
|
|
|
+ void remindPlan_WhenPlanCompleted_ShouldReturn() {
|
|
|
|
|
+ testPlan.setStatus("COMPLETED");
|
|
|
|
|
+ when(operationPlanMapper.selectById(1L)).thenReturn(testPlan);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.remindPlan(1L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(memberMessageService, never()).saveMemberMessage(any(), any(), any(), any());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("完成运维计划-成功")
|
|
|
|
|
+ void completePlan_WhenSuccess_ShouldUpdateStatusAndLog() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(1L)).thenReturn(testPlan);
|
|
|
|
|
+ doNothing().when(operationPlanMapper).updateById(any(OperationPlan.class));
|
|
|
|
|
+ doNothing().when(operationRecordMapper).insert(any(OperationRecord.class));
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.completePlan(1L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationPlanMapper).updateById(argThat(plan ->
|
|
|
|
|
+ "COMPLETED".equals(plan.getStatus())
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationRecordMapper).insert(argThat(record -> {
|
|
|
|
|
+ assertEquals(1L, record.getPlanId());
|
|
|
|
|
+ assertEquals("人工完成计划", record.getContent());
|
|
|
|
|
+ assertEquals("已完成", record.getResult());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("完成运维计划-计划不存在")
|
|
|
|
|
+ void completePlan_WhenPlanNotFound_ShouldReturn() {
|
|
|
|
|
+ when(operationPlanMapper.selectById(999L)).thenReturn(null);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.completePlan(999L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationPlanMapper, never()).updateById(any(OperationPlan.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("分页查询运维记录-成功")
|
|
|
|
|
+ void pageRecord_ShouldReturnPagedRecords() {
|
|
|
|
|
+ when(operationRecordMapper.selectPage(any(Page.class), any(LambdaQueryWrapper.class)))
|
|
|
|
|
+ .thenReturn(new Page<>(1, 10));
|
|
|
|
|
+
|
|
|
|
|
+ var result = operationPlanService.pageRecord(1L, 1, 10);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ verify(operationRecordMapper).selectPage(any(Page.class), argThat(wrapper ->
|
|
|
|
|
+ wrapper != null
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("分页查询我的运维计划-带会员ID和状态")
|
|
|
|
|
+ void pageMyPlans_WithMemberAndStatus_ShouldFilter() {
|
|
|
|
|
+ when(operationPlanMapper.selectPage(any(Page.class), any(LambdaQueryWrapper.class)))
|
|
|
|
|
+ .thenReturn(new Page<>(1, 10));
|
|
|
|
|
+
|
|
|
|
|
+ var result = operationPlanService.pageMyPlans(1L, "IN_PROGRESS", 1, 10);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("分页查询我的运维计划-无过滤")
|
|
|
|
|
+ void pageMyPlans_WithNoFilters_ShouldReturnAll() {
|
|
|
|
|
+ when(operationPlanMapper.selectPage(any(Page.class), any(LambdaQueryWrapper.class)))
|
|
|
|
|
+ .thenReturn(new Page<>(1, 10));
|
|
|
|
|
+
|
|
|
|
|
+ var result = operationPlanService.pageMyPlans(null, null, 1, 10);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("分页查询运维流程模板-带名称和状态")
|
|
|
|
|
+ void pageFlow_WithFilters_ShouldFilter() {
|
|
|
|
|
+ when(operationFlowMapper.selectPage(any(Page.class), any(LambdaQueryWrapper.class)))
|
|
|
|
|
+ .thenReturn(new Page<>(1, 10));
|
|
|
|
|
+
|
|
|
|
|
+ var result = operationPlanService.pageFlow("产品A", "OPEN", 1, 10);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("分页查询运维流程模板-无过滤")
|
|
|
|
|
+ void pageFlow_WithNoFilters_ShouldReturnAll() {
|
|
|
|
|
+ when(operationFlowMapper.selectPage(any(Page.class), any(LambdaQueryWrapper.class)))
|
|
|
|
|
+ .thenReturn(new Page<>(1, 10));
|
|
|
|
|
+
|
|
|
|
|
+ var result = operationPlanService.pageFlow(null, null, 1, 10);
|
|
|
|
|
+
|
|
|
|
|
+ assertNotNull(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("保存运维流程-新增")
|
|
|
|
|
+ void saveFlow_WhenNew_ShouldInsert() {
|
|
|
|
|
+ OperationFlow newFlow = new OperationFlow();
|
|
|
|
|
+ newFlow.setFlowName("新产品流程");
|
|
|
|
|
+ newFlow.setProductId(200L);
|
|
|
|
|
+ newFlow.setStatus("OPEN");
|
|
|
|
|
+
|
|
|
|
|
+ doNothing().when(operationFlowMapper).insert(any(OperationFlow.class));
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.saveFlow(newFlow);
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationFlowMapper).insert(argThat(flow -> {
|
|
|
|
|
+ assertNotNull(flow.getCreateTime());
|
|
|
|
|
+ assertNotNull(flow.getUpdateTime());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("保存运维流程-更新")
|
|
|
|
|
+ void saveFlow_WhenExists_ShouldUpdate() {
|
|
|
|
|
+ testFlow.setFlowName("更新流程名称");
|
|
|
|
|
+ when(operationFlowMapper.selectById(1L)).thenReturn(testFlow);
|
|
|
|
|
+ doNothing().when(operationFlowMapper).updateById(any(OperationFlow.class));
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.saveFlow(testFlow);
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationFlowMapper).updateById(any(OperationFlow.class));
|
|
|
|
|
+ verify(operationFlowMapper, never()).insert(any(OperationFlow.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ @DisplayName("删除运维流程")
|
|
|
|
|
+ void deleteFlow_ShouldDelete() {
|
|
|
|
|
+ doNothing().when(operationFlowMapper).deleteById(1L);
|
|
|
|
|
+
|
|
|
|
|
+ operationPlanService.deleteFlow(1L);
|
|
|
|
|
+
|
|
|
|
|
+ verify(operationFlowMapper).deleteById(1L);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|