|
|
@@ -0,0 +1,59 @@
|
|
|
+package com.etotem.cfc.service;
|
|
|
+
|
|
|
+import com.etotem.cfc.entity.Consignee;
|
|
|
+import com.etotem.cfc.mapper.ConsigneeMapper;
|
|
|
+import com.etotem.cfc.mapper.UserMapper;
|
|
|
+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 static org.mockito.Mockito.*;
|
|
|
+
|
|
|
+@ExtendWith(MockitoExtension.class)
|
|
|
+class ConsigneeServiceBackfillTest {
|
|
|
+
|
|
|
+ @Mock
|
|
|
+ private ConsigneeMapper consigneeMapper;
|
|
|
+
|
|
|
+ @Mock
|
|
|
+ private UserMapper userMapper;
|
|
|
+
|
|
|
+ @Mock
|
|
|
+ private RealNameBackfillService realNameBackfillService;
|
|
|
+
|
|
|
+ @InjectMocks
|
|
|
+ private ConsigneeService consigneeService;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void save_新增分支保存成功后以联系人姓名回填真实姓名() {
|
|
|
+ Consignee consignee = new Consignee();
|
|
|
+ consignee.setUserId(1L);
|
|
|
+ consignee.setName("张三");
|
|
|
+ consignee.setIsDefault(0);
|
|
|
+
|
|
|
+ consigneeService.save(consignee);
|
|
|
+
|
|
|
+ verify(consigneeMapper).insert(consignee);
|
|
|
+ verify(realNameBackfillService).backfill(1L, "张三");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void save_编辑分支保存成功后以联系人姓名回填真实姓名() {
|
|
|
+ Consignee existing = new Consignee();
|
|
|
+ existing.setId(10L);
|
|
|
+ existing.setUserId(1L);
|
|
|
+ when(consigneeMapper.selectById(10L)).thenReturn(existing);
|
|
|
+
|
|
|
+ Consignee consignee = new Consignee();
|
|
|
+ consignee.setId(10L);
|
|
|
+ consignee.setName("李四");
|
|
|
+ consignee.setIsDefault(0);
|
|
|
+
|
|
|
+ consigneeService.save(consignee);
|
|
|
+
|
|
|
+ verify(consigneeMapper).updateById(consignee);
|
|
|
+ verify(realNameBackfillService).backfill(1L, "李四");
|
|
|
+ }
|
|
|
+}
|