暂存提交
This commit is contained in:
+16
-2
@@ -2,19 +2,33 @@ package com.baiyue.integration.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class IntegrationPropertiesTest {
|
||||
@Test
|
||||
void providerIsConfiguredOnlyWhenEnabledAndAllSecretsExist() {
|
||||
var baidu = new IntegrationProperties.BaiduOcr(true, "key", "secret");
|
||||
var baidu = baidu(true, "key", "secret");
|
||||
var amazon = new IntegrationProperties.AmazonSpApi(
|
||||
true, "client", "secret", "refresh", "access", "aws-secret", "us-east-1");
|
||||
|
||||
assertThat(baidu.configured()).isTrue();
|
||||
assertThat(amazon.configured()).isTrue();
|
||||
assertThat(new IntegrationProperties.BaiduOcr(false, "key", "secret").configured()).isFalse();
|
||||
assertThat(baidu(false, "key", "secret").configured()).isFalse();
|
||||
assertThat(new IntegrationProperties.AmazonSpApi(
|
||||
true, "client", "secret", "", "access", "aws-secret", "us-east-1").configured()).isFalse();
|
||||
}
|
||||
|
||||
private IntegrationProperties.BaiduOcr baidu(boolean enabled, String apiKey, String secretKey) {
|
||||
return new IntegrationProperties.BaiduOcr(
|
||||
enabled, apiKey, secretKey,
|
||||
URI.create("https://example.com/token"), URI.create("https://example.com/meter"),
|
||||
Duration.ofSeconds(10), Duration.ofSeconds(60),
|
||||
Path.of("input"), Path.of("output"), null,
|
||||
40_000_000L, 50, Duration.ofMillis(600), 3
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user