65 lines
2.1 KiB
Java
65 lines
2.1 KiB
Java
package com.goldenchart.service;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.goldenchart.dto.TrendSearchRequest;
|
|
import com.goldenchart.entity.GcAppSettings;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
/**
|
|
* 앱 설정 JSON → 스캔 요청 배점 병합 검증.
|
|
*/
|
|
class TrendSearchSettingsHelperTest {
|
|
|
|
private TrendSearchSettingsHelper helper;
|
|
|
|
@BeforeEach
|
|
void setUp() {
|
|
helper = new TrendSearchSettingsHelper(new ObjectMapper());
|
|
}
|
|
|
|
@Test
|
|
void mergeRequestWithSettings_appliesWeightsFromJson() throws Exception {
|
|
GcAppSettings app = GcAppSettings.builder()
|
|
.deviceId("test-device")
|
|
.trendSearchSettingsJson("""
|
|
{"weightMaAlignment":50,"weightMaSlope":10,"weightAdxTrend":15,
|
|
"weightMacdMomentum":10,"weightPricePosition":15,"minTrendScore":60,
|
|
"limit":15,"scanLimit":40}
|
|
""")
|
|
.build();
|
|
|
|
TrendSearchRequest body = new TrendSearchRequest();
|
|
body.setWeightMaAlignment(30);
|
|
body.setMinTrendScore(70);
|
|
|
|
TrendSearchRequest merged = helper.mergeRequestWithSettings(body, app);
|
|
|
|
assertEquals(50, merged.getWeightMaAlignment());
|
|
assertEquals(10, merged.getWeightMaSlope());
|
|
assertEquals(15, merged.getWeightAdxTrend());
|
|
assertEquals(60, merged.getMinTrendScore());
|
|
assertEquals(15, merged.getLimit());
|
|
assertEquals(40, merged.getScanLimit());
|
|
}
|
|
|
|
@Test
|
|
void buildRequest_usesLastRequestTimeframe_whenPresent() throws Exception {
|
|
GcAppSettings app = GcAppSettings.builder()
|
|
.defaultTimeframe("1D")
|
|
.trendSearchSettingsJson("{\"weightMaAlignment\":25}")
|
|
.build();
|
|
|
|
TrendSearchRequest last = new TrendSearchRequest();
|
|
last.setTimeframe("4h");
|
|
last.setWeightMaAlignment(99);
|
|
|
|
TrendSearchRequest built = helper.buildRequest(app, last);
|
|
|
|
assertEquals("4h", built.getTimeframe());
|
|
assertEquals(25, built.getWeightMaAlignment());
|
|
}
|
|
}
|