직접입력값 평가오류 수정
This commit is contained in:
+49
-7
@@ -5,14 +5,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class StrategyConditionThresholdNormalizerTest {
|
||||
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
@Test
|
||||
void normalizesK50OverrideToHlMid() throws Exception {
|
||||
void preservesK50DirectInput() throws Exception {
|
||||
JsonNode root = MAPPER.readTree("""
|
||||
{
|
||||
"type": "CONDITION",
|
||||
@@ -29,11 +29,53 @@ class StrategyConditionThresholdNormalizerTest {
|
||||
}
|
||||
""");
|
||||
|
||||
JsonNode normalized = StrategyConditionThresholdNormalizer.normalizeTree(root);
|
||||
JsonNode cond = normalized.path("condition");
|
||||
JsonNode cond = StrategyConditionThresholdNormalizer.normalizeTree(root).path("condition");
|
||||
|
||||
assertEquals("HL_MID", cond.path("rightField").asText());
|
||||
assertFalse(cond.path("thresholdOverride").asBoolean(true));
|
||||
assertFalse(cond.has("targetValue"));
|
||||
assertEquals("K_50", cond.path("rightField").asText());
|
||||
assertTrue(cond.path("thresholdOverride").asBoolean(false));
|
||||
assertEquals(50.0, cond.path("targetValue").asDouble(), 0.0001);
|
||||
}
|
||||
|
||||
@Test
|
||||
void preservesK55DirectInput() throws Exception {
|
||||
JsonNode root = MAPPER.readTree("""
|
||||
{
|
||||
"type": "CONDITION",
|
||||
"condition": {
|
||||
"indicatorType": "RSI",
|
||||
"conditionType": "CROSS_UP",
|
||||
"leftField": "RSI_VALUE",
|
||||
"rightField": "K_55",
|
||||
"thresholdOverride": true,
|
||||
"targetValue": 55
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
JsonNode cond = StrategyConditionThresholdNormalizer.normalizeTree(root).path("condition");
|
||||
|
||||
assertEquals("K_55", cond.path("rightField").asText());
|
||||
assertTrue(cond.path("thresholdOverride").asBoolean(false));
|
||||
assertEquals(55.0, cond.path("targetValue").asDouble(), 0.0001);
|
||||
}
|
||||
|
||||
@Test
|
||||
void fillsTargetValueFromKFieldWhenMissing() throws Exception {
|
||||
JsonNode root = MAPPER.readTree("""
|
||||
{
|
||||
"type": "CONDITION",
|
||||
"condition": {
|
||||
"indicatorType": "RSI",
|
||||
"rightField": "K_55",
|
||||
"thresholdOverride": false
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
JsonNode cond = StrategyConditionThresholdNormalizer.normalizeTree(root).path("condition");
|
||||
|
||||
assertEquals("K_55", cond.path("rightField").asText());
|
||||
assertTrue(cond.path("thresholdOverride").asBoolean(false));
|
||||
assertEquals(55.0, cond.path("targetValue").asDouble(), 0.0001);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user