File size: 3,123 Bytes
442299c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package com.dalab.discovery.sd.config;

import java.util.Collections;
import java.util.Map;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

import com.dalab.discovery.common.config.cloud.impl.aws.AWSConfigService;
import com.dalab.discovery.common.config.cloud.impl.azure.AzureConfigService;
import com.dalab.discovery.common.config.cloud.impl.oracle.OracleConfigService;
import com.dalab.discovery.common.model.ResourceType;

/**
 * Test configuration that provides mock implementations for various services.
 */
@TestConfiguration
public class TestConfig {

	/**
	 * Provides a mock AWSConfigService for tests if none is present.
	 */
	@Bean
	@ConditionalOnMissingBean
	@Primary
	public AWSConfigService mockAwsConfigService() {
		return new AWSConfigService() {
			@Override
			public String getAccessKey() {
				return "test-access-key";
			}

			@Override
			public String getSecretKey() {
				return "test-secret-key";
			}

			@Override
			public String getRegion() {
				return "us-west-2";
			}

			@Override
			public boolean isSsmEnabled() {
				return false;
			}

			@Override
			public String getSsmPrefix() {
				return "/test-prefix/";
			}

			@Override
			public String getS3BucketName() {
				return "test-bucket";
			}

			@Override
			public String getDynamoDBTableName() {
				return "test-table";
			}

			@Override
			public Map<String, String> getTags(ResourceType resourceType) {
				return Collections.emptyMap();
			}

			@Override
			public String getAccountId() {
				return "test-account-id";
			}
		};
	}

	/**
	 * Provides a mock AzureConfigService for tests if none is present.
	 */
	@Bean
	@ConditionalOnMissingBean
	@Primary
	public AzureConfigService mockAzureConfigService() {
		return new AzureConfigService() {
			@Override
			public String getClientId() {
				return "test-client-id";
			}

			@Override
			public String getClientSecret() {
				return "test-client-secret";
			}

			@Override
			public String getTenantId() {
				return "test-tenant-id";
			}

			// If AzureConfigService has other abstract methods, implement them here
		};
	}

	/**
	 * Provides a mock OracleConfigService for tests if none is present.
	 */
	@Bean
	@ConditionalOnMissingBean
	@Primary
	public OracleConfigService mockOracleConfigService() {
		return new OracleConfigService() {
			@Override
			public String getConfigFilePath() {
				return "classpath:config/test-oci-config";
			}

			@Override
			public String getProfileName() {
				return "DEFAULT";
			}

			@Override
			public String getTenancyId() {
				return "test-tenancy-id";
			}

			@Override
			public String getRegion() {
				return "us-phoenix-1";
			}

			@Override
			public String getDefaultCompartment() {
				return "test-compartment";
			}

			@Override
			public String getCompartmentId() {
				return "test-compartment-id";
			}

			// If OracleConfigService has other abstract methods, implement them here
		};
	}
}