|
21 | 21 | import static org.assertj.core.api.Assertions.assertThat; |
22 | 22 |
|
23 | 23 | import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; |
| 24 | +import java.util.Arrays; |
24 | 25 | import java.util.Collections; |
25 | 26 | import java.util.HashMap; |
| 27 | +import java.util.List; |
26 | 28 | import java.util.Map; |
27 | 29 | import org.junit.jupiter.api.Test; |
28 | 30 |
|
29 | 31 | class ResourcesAutoConfigurationTest { |
30 | 32 |
|
31 | | - public static final String GCP_ENABLED = "otel.resource.providers.gcp.enabled"; |
32 | | - public static final String AWS_ENABLED = "otel.resource.providers.aws.enabled"; |
| 33 | + private static final List<String> LIST = |
| 34 | + Arrays.asList(config("gcp"), config("aws"), config("azure")); |
| 35 | + |
| 36 | + private static String config(String provider) { |
| 37 | + return String.format("otel.resource.providers.%s.enabled", provider); |
| 38 | + } |
33 | 39 |
|
34 | 40 | @Test |
35 | 41 | void elastic_defaults() { |
36 | 42 | // default everything should be enabled |
37 | 43 |
|
38 | 44 | Map<String, String> explicitConfig = Collections.emptyMap(); |
39 | 45 | Map<String, String> expectedResult = new HashMap<>(); |
40 | | - expectedResult.put(GCP_ENABLED, "true"); |
41 | | - expectedResult.put(AWS_ENABLED, "true"); |
| 46 | + |
| 47 | + LIST.forEach(v -> expectedResult.put(v, "true")); |
42 | 48 |
|
43 | 49 | testConfig(explicitConfig, expectedResult); |
44 | 50 | } |
45 | 51 |
|
46 | 52 | @Test |
47 | 53 | void explicitly_enabled() { |
48 | 54 | Map<String, String> explicitConfig = new HashMap<>(); |
49 | | - explicitConfig.put(GCP_ENABLED, "true"); |
| 55 | + explicitConfig.put(LIST.get(0), "true"); |
50 | 56 |
|
51 | 57 | Map<String, String> expectedResult = new HashMap<>(); |
52 | | - expectedResult.put(GCP_ENABLED, "true"); |
53 | | - expectedResult.put(AWS_ENABLED, "true"); |
| 58 | + LIST.forEach(v -> expectedResult.put(v, "true")); |
54 | 59 |
|
55 | 60 | testConfig(explicitConfig, expectedResult); |
56 | 61 | } |
57 | 62 |
|
58 | 63 | @Test |
59 | 64 | void explicitly_disabled() { |
60 | 65 | Map<String, String> explicitConfig = new HashMap<>(); |
61 | | - explicitConfig.put(GCP_ENABLED, "false"); |
| 66 | + explicitConfig.put(LIST.get(0), "false"); |
62 | 67 |
|
63 | 68 | Map<String, String> expectedResult = new HashMap<>(); |
64 | | - expectedResult.put(GCP_ENABLED, "false"); |
65 | | - expectedResult.put(AWS_ENABLED, "true"); |
| 69 | + expectedResult.put(LIST.get(0), "false"); |
| 70 | + for (int i = 1; i < LIST.size(); i++) { |
| 71 | + expectedResult.put(LIST.get(i), "true"); |
| 72 | + } |
66 | 73 |
|
67 | 74 | testConfig(explicitConfig, expectedResult); |
68 | 75 | } |
|
0 commit comments