企微前后台联调。

This commit is contained in:
2026-04-24 20:54:14 +08:00
parent 1f7b1e6d55
commit 1627e486a2
7 changed files with 26 additions and 14 deletions

View File

@@ -49,9 +49,10 @@ public class QweiDepartmentControllerTest {
serviceResult.put("inserted", 3);
serviceResult.put("updated", 5);
serviceResult.put("total", 8);
when(qweiDepartmentService.syncFromQiWei()).thenReturn(serviceResult);
when(qweiDepartmentService.syncFromQiWei("TENANT_TEST")).thenReturn(serviceResult);
mockMvc.perform(post("/api/qweiDepartment/sync")
.param("tenantId", "TENANT_TEST")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
@@ -59,7 +60,7 @@ public class QweiDepartmentControllerTest {
.andExpect(jsonPath("$.updated").value(5))
.andExpect(jsonPath("$.total").value(8));
verify(qweiDepartmentService, times(1)).syncFromQiWei();
verify(qweiDepartmentService, times(1)).syncFromQiWei("TENANT_TEST");
}
@Test
@@ -67,14 +68,15 @@ public class QweiDepartmentControllerTest {
Map<String, Object> serviceResult = new HashMap<>();
serviceResult.put("success", false);
serviceResult.put("message", "同步异常:测试错误");
when(qweiDepartmentService.syncFromQiWei()).thenReturn(serviceResult);
when(qweiDepartmentService.syncFromQiWei("TENANT_TEST")).thenReturn(serviceResult);
mockMvc.perform(post("/api/qweiDepartment/sync")
.param("tenantId", "TENANT_TEST")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest())
.andExpect(jsonPath("$.success").value(false));
verify(qweiDepartmentService, times(1)).syncFromQiWei();
verify(qweiDepartmentService, times(1)).syncFromQiWei("TENANT_TEST");
}
}