|
|
@@ -0,0 +1,130 @@
|
|
|
+package com.etotem.cfc.unit;
|
|
|
+
|
|
|
+import com.etotem.cfc.service.FamilyMemberDimensionBaseScoreService;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
+import org.mockito.InjectMocks;
|
|
|
+import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
+
|
|
|
+@ExtendWith(MockitoExtension.class)
|
|
|
+class FamilyMemberDimensionBaseScoreServiceTest {
|
|
|
+
|
|
|
+ @InjectMocks
|
|
|
+ private FamilyMemberDimensionBaseScoreService service;
|
|
|
+
|
|
|
+ private Map<String, Integer> wuxing(int wood, int fire, int earth, int metal, int water) {
|
|
|
+ Map<String, Integer> m = new HashMap<>();
|
|
|
+ m.put("wood", wood);
|
|
|
+ m.put("fire", fire);
|
|
|
+ m.put("earth", earth);
|
|
|
+ m.put("metal", metal);
|
|
|
+ m.put("water", water);
|
|
|
+ return m;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void calcBaseScores_fullData_returnsCorrectScores() {
|
|
|
+ // 八字五行 {wood:40, fire:60, earth:50, metal:30, water:20}
|
|
|
+ // 星座狮子座(火象→心)
|
|
|
+ // 灵数7(→智)
|
|
|
+ Map<String, Integer> result = service.calcBaseScores(wuxing(40, 60, 50, 30, 20), "狮子座", 7);
|
|
|
+
|
|
|
+ assertEquals(30, result.get("body")); // 50×0.6=30
|
|
|
+ assertEquals(56, result.get("mind")); // 60×0.6+20=56
|
|
|
+ assertEquals(38, result.get("wisdom")); // 30×0.6+20=38
|
|
|
+ assertEquals(24, result.get("action")); // 40×0.6=24
|
|
|
+ assertEquals(12, result.get("wealth")); // 20×0.6=12
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void calcBaseScores_nullWuxing_returnsNeutral50() {
|
|
|
+ Map<String, Integer> result = service.calcBaseScores(null, null, null);
|
|
|
+
|
|
|
+ assertEquals(50, result.get("body"));
|
|
|
+ assertEquals(50, result.get("mind"));
|
|
|
+ assertEquals(50, result.get("wisdom"));
|
|
|
+ assertEquals(50, result.get("action"));
|
|
|
+ assertEquals(50, result.get("wealth"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void calcBaseScores_masterNumber_11MapsTo2() {
|
|
|
+ // 灵数11→化简为2→映射到心(mind),星座null
|
|
|
+ Map<String, Integer> result = service.calcBaseScores(wuxing(50, 50, 50, 50, 50), null, 11);
|
|
|
+
|
|
|
+ // fire=50, 50×0.6=30, 灵数11→2→心(mind) → 30+20=50
|
|
|
+ assertEquals(50, result.get("mind"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void calcBaseScores_masterNumber_22MapsTo4() {
|
|
|
+ Map<String, Integer> result = service.calcBaseScores(wuxing(50, 50, 50, 50, 50), null, 22);
|
|
|
+ // 22→4→身(body=earth)
|
|
|
+ // earth=50, 50×0.6=30, 30+20=50
|
|
|
+ assertEquals(50, result.get("body"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void calcBaseScores_allZodiacSigns_coverage() {
|
|
|
+ // 使用非均匀五行值,使命中维度 > 中性线
|
|
|
+ Map<String, Integer> w = wuxing(60, 80, 60, 60, 60);
|
|
|
+ // 各维度基础分: action=36, mind=48, body=36, wisdom=36, wealth=36
|
|
|
+
|
|
|
+ // 火象 → 心(mind): 48+20=68 > 50 ✓
|
|
|
+ Map<String, Integer> fireResult = service.calcBaseScores(w, "白羊座", null);
|
|
|
+ assertTrue(fireResult.get("mind") > 50);
|
|
|
+
|
|
|
+ // 土象 → 身(body): 36+20=56 > 50 ✓
|
|
|
+ Map<String, Integer> earthResult = service.calcBaseScores(w, "金牛座", null);
|
|
|
+ assertTrue(earthResult.get("body") > 50);
|
|
|
+
|
|
|
+ // 风象 → 行(action): 36+20=56 > 50 ✓
|
|
|
+ Map<String, Integer> airResult = service.calcBaseScores(w, "双子座", null);
|
|
|
+ assertTrue(airResult.get("action") > 50);
|
|
|
+
|
|
|
+ // 水象 → 富(wealth): 36+20=56 > 50 ✓
|
|
|
+ Map<String, Integer> waterResult = service.calcBaseScores(w, "巨蟹座", null);
|
|
|
+ assertTrue(waterResult.get("wealth") > 50);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void calcBaseScores_all12ZodiacSigns() {
|
|
|
+ Map<String, Integer> w = wuxing(60, 80, 60, 60, 60);
|
|
|
+
|
|
|
+ // 火象 3个
|
|
|
+ service.calcBaseScores(w, "狮子座", null);
|
|
|
+ service.calcBaseScores(w, "射手座", null);
|
|
|
+
|
|
|
+ // 土象 3个
|
|
|
+ service.calcBaseScores(w, "处女座", null);
|
|
|
+ service.calcBaseScores(w, "摩羯座", null);
|
|
|
+
|
|
|
+ // 风象 3个
|
|
|
+ service.calcBaseScores(w, "天秤座", null);
|
|
|
+ service.calcBaseScores(w, "水瓶座", null);
|
|
|
+
|
|
|
+ // 水象 3个
|
|
|
+ service.calcBaseScores(w, "天蝎座", null);
|
|
|
+ service.calcBaseScores(w, "双鱼座", null);
|
|
|
+
|
|
|
+ // 所有12个星座不应抛异常;白羊座(火→心): 48+20=68
|
|
|
+ Map<String, Integer> result = service.calcBaseScores(w, "白羊座", null);
|
|
|
+ assertEquals(68, result.get("mind"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void calcBaseScores_unknownZodiacNoBonus() {
|
|
|
+ // wuxing全null时,各维度默认50;未知星座不应加分
|
|
|
+ Map<String, Integer> result = service.calcBaseScores(null, "未知星座", null);
|
|
|
+ assertEquals(50, result.get("body"));
|
|
|
+ assertEquals(50, result.get("mind"));
|
|
|
+ assertEquals(50, result.get("wisdom"));
|
|
|
+ assertEquals(50, result.get("action"));
|
|
|
+ assertEquals(50, result.get("wealth"));
|
|
|
+ }
|
|
|
+}
|