fix(selfop): remove obsolete execution binding on config refresh
This commit is contained in:
Vendored
-1
@@ -30,7 +30,6 @@ SELFOP_SOURCE_ACCOUNT=lingxing-primary
|
||||
# 未核准额度使用0,真实出口拒绝请求;有效模式仍需显式的独占交接证明与截止时间。
|
||||
SELFOP_DAILY_REQUEST_BUDGET=0
|
||||
SELFOP_MIN_REQUEST_INTERVAL_MS=5000
|
||||
SELFOP_EXECUTION_ENABLED=false
|
||||
SELFOP_SALES_PUBLICATION_ENABLED=false
|
||||
REDIS_PASSWORD=
|
||||
AUTH_DB_URL=jdbc:mysql://host.docker.internal:3306/baiyue_auth?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
|
||||
@@ -52,7 +52,6 @@ baiyue:
|
||||
environment: ${DEPLOY_ENV:test}
|
||||
daily-request-budget: ${SELFOP_DAILY_REQUEST_BUDGET:0}
|
||||
business-min-request-interval-ms: ${SELFOP_MIN_REQUEST_INTERVAL_MS:5000}
|
||||
execution-enabled: ${SELFOP_EXECUTION_ENABLED:false}
|
||||
sales-publication-enabled: ${SELFOP_SALES_PUBLICATION_ENABLED:false}
|
||||
integration-base-url: http://integration-service:9210
|
||||
internal-service-token: ${INTERNAL_SERVICE_TOKEN:}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.baiyue.lastleg.selfoperated.analytics.model;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.context.properties.bind.Bindable;
|
||||
import org.springframework.boot.context.properties.bind.BindException;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.env.YamlPropertySourceLoader;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import java.util.Map;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class SelfopAnalyticsPropertiesBindingTest {
|
||||
StandardEnvironment environment() throws Exception {
|
||||
var env=new StandardEnvironment();
|
||||
for(var source:new YamlPropertySourceLoader().load("application",new ClassPathResource("application.yml")))env.getPropertySources().addLast(source);
|
||||
env.getPropertySources().addFirst(new MapPropertySource("runtime",Map.of(
|
||||
"baiyue.self-operated-analytics.collection-mode","BUSINESS",
|
||||
"baiyue.self-operated-analytics.environment","test",
|
||||
"baiyue.self-operated-analytics.inventory-history-enabled",true)));
|
||||
return env;
|
||||
}
|
||||
@Test void refreshingRunningBusinessBeanBindsHistoryFlagWithoutDerivedExecutionInput() throws Exception {
|
||||
var config=new SelfopAnalyticsProperties();config.setCollectionMode("BUSINESS");
|
||||
var env=environment();
|
||||
assertNull(env.getProperty("baiyue.self-operated-analytics.execution-enabled"));
|
||||
Binder.get(env).bind("baiyue.self-operated-analytics",Bindable.ofInstance(config));
|
||||
assertTrue(config.isInventoryHistoryEnabled());assertTrue(config.isExecutionEnabled());
|
||||
Binder.get(env).bind("baiyue.self-operated-analytics",Bindable.ofInstance(config));
|
||||
assertTrue(config.isInventoryHistoryEnabled());assertTrue(config.isExecutionEnabled());
|
||||
}
|
||||
@Test void obsoleteFalseInputReproducesTheRefreshFailure() throws Exception {
|
||||
var config=new SelfopAnalyticsProperties();config.setCollectionMode("BUSINESS");
|
||||
var env=environment();env.getPropertySources().addFirst(new MapPropertySource("obsolete",Map.of("baiyue.self-operated-analytics.execution-enabled",false)));
|
||||
assertThrows(BindException.class,()->Binder.get(env).bind("baiyue.self-operated-analytics",Bindable.ofInstance(config)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user