Search in sources :

Example 1 with StaticMetadataManager

use of com.tencent.cloud.common.metadata.StaticMetadataManager in project spring-cloud-tencent by Tencent.

the class PolarisRegistrationTest method setUp.

@Before
public void setUp() {
    // mock DiscoveryPropertiesAutoConfiguration
    DiscoveryPropertiesAutoConfiguration discoveryPropertiesAutoConfiguration = mock(DiscoveryPropertiesAutoConfiguration.class);
    doReturn(true).when(discoveryPropertiesAutoConfiguration).isRegisterEnabled();
    // mock PolarisDiscoveryProperties
    PolarisDiscoveryProperties polarisDiscoveryProperties = mock(PolarisDiscoveryProperties.class);
    doReturn(SERVICE_PROVIDER).when(polarisDiscoveryProperties).getService();
    doReturn(PORT).when(polarisDiscoveryProperties).getPort();
    doReturn("http").when(polarisDiscoveryProperties).getProtocol();
    // mock SDKContext
    APIConfig apiConfig = mock(APIConfig.class);
    doReturn(HOST).when(apiConfig).getBindIP();
    GlobalConfig globalConfig = mock(GlobalConfig.class);
    doReturn(apiConfig).when(globalConfig).getAPI();
    Configuration configuration = mock(Configuration.class);
    doReturn(globalConfig).when(configuration).getGlobal();
    SDKContext polarisContext = mock(SDKContext.class);
    doReturn(configuration).when(polarisContext).getConfig();
    // mock StaticMetadataManager
    StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
    doReturn(Collections.singletonMap("key1", "value1")).when(staticMetadataManager).getMergedStaticMetadata();
    doReturn(Collections.singletonMap("key2", "value2")).when(staticMetadataManager).getLocationMetadata();
    polarisRegistration = new PolarisRegistration(discoveryPropertiesAutoConfiguration, polarisDiscoveryProperties, polarisContext, staticMetadataManager);
}
Also used : SDKContext(com.tencent.polaris.client.api.SDKContext) DiscoveryPropertiesAutoConfiguration(com.tencent.cloud.polaris.DiscoveryPropertiesAutoConfiguration) Configuration(com.tencent.polaris.api.config.Configuration) PolarisDiscoveryProperties(com.tencent.cloud.polaris.PolarisDiscoveryProperties) APIConfig(com.tencent.polaris.api.config.global.APIConfig) GlobalConfig(com.tencent.polaris.api.config.global.GlobalConfig) StaticMetadataManager(com.tencent.cloud.common.metadata.StaticMetadataManager) DiscoveryPropertiesAutoConfiguration(com.tencent.cloud.polaris.DiscoveryPropertiesAutoConfiguration) Before(org.junit.Before)

Aggregations

StaticMetadataManager (com.tencent.cloud.common.metadata.StaticMetadataManager)1 DiscoveryPropertiesAutoConfiguration (com.tencent.cloud.polaris.DiscoveryPropertiesAutoConfiguration)1 PolarisDiscoveryProperties (com.tencent.cloud.polaris.PolarisDiscoveryProperties)1 Configuration (com.tencent.polaris.api.config.Configuration)1 APIConfig (com.tencent.polaris.api.config.global.APIConfig)1 GlobalConfig (com.tencent.polaris.api.config.global.GlobalConfig)1 SDKContext (com.tencent.polaris.client.api.SDKContext)1 Before (org.junit.Before)1