Przeglądaj źródła

test: 新增 PricingController 和 AcademicOrientation 控制层测试

覆盖 /api/pricing/current, /api/pricing/upgrade, /api/chart/academic-orientation 三个端点

Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
liaoxg 5 miesięcy temu
rodzic
commit
f52636a935

+ 58 - 0
num-server/src/test/java/com/etotem/num/controller/ControllerIntegrationTest.java

@@ -784,4 +784,62 @@ class ControllerIntegrationTest {
                 .andExpect(jsonPath("$.code").value(0))
                 .andExpect(jsonPath("$.code").value(0))
                 .andExpect(jsonPath("$.data.exists").value(false));
                 .andExpect(jsonPath("$.data.exists").value(false));
     }
     }
+
+    // ==================== PricingController ====================
+
+    @Test
+    void testPricingCurrent() throws Exception {
+        when(configService.getInt("pricing.practitioner.seed", 131400)).thenReturn(131400);
+        when(configService.getInt("pricing.practitioner.standard", 198600)).thenReturn(198600);
+        when(configService.getInt("pricing.annual", 13100)).thenReturn(13100);
+        when(configService.getInt("pricing.practitioner.seed_limit", 300)).thenReturn(300);
+
+        mockMvc.perform(post("/api/pricing/current")
+                        .header("Authorization", "Bearer " + userToken)
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.code").value(0))
+                .andExpect(jsonPath("$.data.seedPrice").value(131400))
+                .andExpect(jsonPath("$.data.standardPrice").value(198600))
+                .andExpect(jsonPath("$.data.annualFee").value(13100))
+                .andExpect(jsonPath("$.data.isSeedPrice").value(true))
+                .andExpect(jsonPath("$.data.remainingSeats").value(300))
+                .andExpect(jsonPath("$.data.seedLimit").value(300));
+    }
+
+    @Test
+    void testPricingUpgrade() throws Exception {
+        when(configService.getInt("pricing.practitioner.seed", 131400)).thenReturn(131400);
+        when(configService.getInt("pricing.practitioner.standard", 198600)).thenReturn(198600);
+        when(configService.getInt("pricing.annual", 13100)).thenReturn(13100);
+        when(configService.getInt("pricing.practitioner.seed_limit", 300)).thenReturn(300);
+
+        mockMvc.perform(post("/api/pricing/upgrade")
+                        .header("Authorization", "Bearer " + userToken)
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.code").value(0))
+                .andExpect(jsonPath("$.data.practitionerSeedPrice").value(131400))
+                .andExpect(jsonPath("$.data.practitionerStandardPrice").value(198600))
+                .andExpect(jsonPath("$.data.isSeedPrice").value(true))
+                .andExpect(jsonPath("$.data.upgradePrice").isNumber());
+    }
+
+    // ==================== AcademicOrientation ====================
+
+    @Test
+    void testAcademicOrientation() throws Exception {
+        Map<String, Object> mockResult = new HashMap<>();
+        mockResult.put("talentTendency", Collections.singletonMap("title", "天赋倾向"));
+        when(chartService.getAcademicOrientation(100L, 10L))
+                .thenReturn(mockResult);
+
+        mockMvc.perform(post("/api/chart/academic-orientation")
+                        .header("Authorization", "Bearer " + userToken)
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content("{\"chartRecordId\":10}"))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.code").value(0))
+                .andExpect(jsonPath("$.data.talentTendency.title").value("天赋倾向"));
+    }
 }
 }