feat: channel group echo

main
13009 2024-07-03 16:48:17 +08:00
parent 6b8af9d4a3
commit e277a97b5c
4 changed files with 13 additions and 8 deletions

View File

@ -53,7 +53,7 @@ public abstract class AbstractAutoConfiguration {
.channelNo(getProperties().getChannel().getChannelNo()) .channelNo(getProperties().getChannel().getChannelNo())
.appNo(getProperties().getChannel().getAppNo()); .appNo(getProperties().getChannel().getAppNo());
if (getProperties().getChannel().isChannelGroupMode()) { if (Boolean.TRUE.equals(getProperties().getChannel().getChannelGroupMode())) {
builder.enableChannelGroupMode(); builder.enableChannelGroupMode();
} }

View File

@ -56,7 +56,7 @@ public class ScfsApiGatewayProperties {
/** /**
* false * false
*/ */
private boolean channelGroupMode = false; private Boolean channelGroupMode = false;
} }
@Data @Data

View File

@ -39,7 +39,7 @@ class ScfsApiGatewayPropertiesTest {
properties.setChannel(channel); properties.setChannel(channel);
Assertions.assertNotNull(properties.getChannel()); Assertions.assertNotNull(properties.getChannel());
Assertions.assertFalse(channel.isChannelGroupMode()); Assertions.assertFalse(channel.getChannelGroupMode());
assertThatJson("{\"channelNo\":\"000000\",\"appNo\":\"111111\",\"channelGroupMode\":false}").isEqualTo(properties.getChannel()); assertThatJson("{\"channelNo\":\"000000\",\"appNo\":\"111111\",\"channelGroupMode\":false}").isEqualTo(properties.getChannel());

View File

@ -19,7 +19,7 @@ class SmConfigurationTest {
private SmConfiguration smConfiguration; private SmConfiguration smConfiguration;
private ScfsApiGatewayProperties properties() { private ScfsApiGatewayProperties properties(boolean channelGroupMode) {
ScfsApiGatewayProperties properties = new ScfsApiGatewayProperties(); ScfsApiGatewayProperties properties = new ScfsApiGatewayProperties();
ScfsApiGatewayProperties.Httpclient httpclient = new ScfsApiGatewayProperties.Httpclient(); ScfsApiGatewayProperties.Httpclient httpclient = new ScfsApiGatewayProperties.Httpclient();
@ -28,7 +28,9 @@ class SmConfigurationTest {
httpclient.setHeaders(headers); httpclient.setHeaders(headers);
ScfsApiGatewayProperties.Httpclient.Proxy proxy = new ScfsApiGatewayProperties.Httpclient.Proxy(); ScfsApiGatewayProperties.Httpclient.Proxy proxy = new ScfsApiGatewayProperties.Httpclient.Proxy();
if (channelGroupMode) {
proxy.setEnabled(true); proxy.setEnabled(true);
}
proxy.setHost("128.0.0.1"); proxy.setHost("128.0.0.1");
proxy.setPort("1000"); proxy.setPort("1000");
proxy.setUsername("name"); proxy.setUsername("name");
@ -49,6 +51,9 @@ class SmConfigurationTest {
ScfsApiGatewayProperties.Channel channel = new ScfsApiGatewayProperties.Channel(); ScfsApiGatewayProperties.Channel channel = new ScfsApiGatewayProperties.Channel();
channel.setChannelNo("000000"); channel.setChannelNo("000000");
channel.setAppNo("111111"); channel.setAppNo("111111");
if (channelGroupMode) {
channel.setChannelGroupMode(true);
}
properties.setChannel(channel); properties.setChannel(channel);
ScfsApiGatewayProperties.Cipher cipher = new ScfsApiGatewayProperties.Cipher(); ScfsApiGatewayProperties.Cipher cipher = new ScfsApiGatewayProperties.Cipher();
@ -65,17 +70,17 @@ class SmConfigurationTest {
@Test @Test
void getProperties() { void getProperties() {
smConfiguration = new SmConfiguration(properties()); smConfiguration = new SmConfiguration(properties(false));
ScfsApiGatewayProperties properties = smConfiguration.getProperties(); ScfsApiGatewayProperties properties = smConfiguration.getProperties();
Assertions.assertNotNull(properties); Assertions.assertNotNull(properties);
} }
@Test @Test
void smProfile() { void smProfile() {
smConfiguration = new SmConfiguration(properties()); smConfiguration = new SmConfiguration(properties(true));
SmProfile smProfile = smConfiguration.smProfile(); SmProfile smProfile = smConfiguration.smProfile();
Assertions.assertNotNull(smProfile); Assertions.assertNotNull(smProfile);
assertThatJson("{\"appNo\":\"111111\",\"channelNo\":\"000000\",\"channelGroupMode\":false}").isEqualTo(smProfile.getChannel()); assertThatJson("{\"appNo\":\"111111\",\"channelNo\":\"000000\",\"channelGroupMode\":true}").isEqualTo(smProfile.getChannel());
assertThatJson("{\"host\":\"http://127.0.0.1\",\"connPool\":{\"maxRequests\":100,\"maxRequestPerHost\":100,\"connectTimeout\":100,\"socketTimeout\":100},\"headers\":{\"aa\":\"123456\"},\"proxy\":{\"enabled\":true,\"host\":\"128.0.0.1\",\"port\":\"1000\",\"username\":\"name\",\"password\":\"123456\",\"scheme\":\"https\"}}\n") assertThatJson("{\"host\":\"http://127.0.0.1\",\"connPool\":{\"maxRequests\":100,\"maxRequestPerHost\":100,\"connectTimeout\":100,\"socketTimeout\":100},\"headers\":{\"aa\":\"123456\"},\"proxy\":{\"enabled\":true,\"host\":\"128.0.0.1\",\"port\":\"1000\",\"username\":\"name\",\"password\":\"123456\",\"scheme\":\"https\"}}\n")
.isEqualTo(smProfile.getHttpProfile()); .isEqualTo(smProfile.getHttpProfile());
} }