|
|
@@ -0,0 +1,45 @@
|
|
|
+package com.etotem.cfc.integration.controller;
|
|
|
+
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.controller.admin.AdminFamilyOverviewController;
|
|
|
+import com.etotem.cfc.dto.FamilyOverviewDTO;
|
|
|
+import com.etotem.cfc.service.FamilyAdminOverviewService;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.boot.test.mock.mockito.MockBean;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
+import static org.mockito.ArgumentMatchers.*;
|
|
|
+import static org.mockito.Mockito.when;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 管理端家庭信息查看接口测试。
|
|
|
+ * 注意:@SpringBootTest 需显式指定 datasource URL(生产库 192.168.16.251 不可达),
|
|
|
+ * 使用本机 MariaDB(127.0.0.1:3306/zxyj)——与 Task 2/4 预批准覆盖一致。
|
|
|
+ */
|
|
|
+@SpringBootTest(properties = {
|
|
|
+ "spring.datasource.url=jdbc:mysql://127.0.0.1:3306/zxyj?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true",
|
|
|
+ "spring.datasource.username=zxyj",
|
|
|
+ "spring.datasource.password=zxyj@123"
|
|
|
+})
|
|
|
+public class AdminFamilyOverviewControllerTest {
|
|
|
+ @Resource private AdminFamilyOverviewController ctrl;
|
|
|
+ @MockBean private FamilyAdminOverviewService svc;
|
|
|
+
|
|
|
+ @Test void overview_非admin拒绝() {
|
|
|
+ Result<FamilyOverviewDTO> r = ctrl.getOverview(7L, "parent");
|
|
|
+ assertTrue(r.getCode() != 200);
|
|
|
+ }
|
|
|
+ @Test void overview_成功() {
|
|
|
+ when(svc.buildOverview(7L)).thenReturn(new FamilyOverviewDTO());
|
|
|
+ Result<FamilyOverviewDTO> r = ctrl.getOverview(7L, "admin");
|
|
|
+ assertEquals(200, r.getCode());
|
|
|
+ assertNotNull(r.getData());
|
|
|
+ }
|
|
|
+ @Test void tasks_分页() {
|
|
|
+ when(svc.pageTasks(eq(7L), anyLong(), anyLong())).thenReturn(new Page<>());
|
|
|
+ Result<Page<com.etotem.cfc.dto.TaskItemVO>> r = ctrl.getTasks(7L, null, "admin");
|
|
|
+ assertEquals(200, r.getCode());
|
|
|
+ }
|
|
|
+}
|