-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8931db3
commit 0956a57
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...covery/src/test/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available. | ||
* | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed | ||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.tencent.cloud.polaris.discovery; | ||
|
||
import com.tencent.cloud.polaris.PolarisDiscoveryProperties; | ||
import com.tencent.cloud.polaris.context.PolarisSDKContextManager; | ||
import com.tencent.polaris.api.core.ConsumerAPI; | ||
import com.tencent.polaris.api.exception.PolarisException; | ||
import com.tencent.polaris.api.rpc.ServicesResponse; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static com.tencent.polaris.test.common.Consts.NAMESPACE_TEST; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.mock; | ||
|
||
/** | ||
* Test for {@link PolarisDiscoveryHandler}. | ||
* | ||
* @author Haotian Zhang | ||
*/ | ||
@ExtendWith(MockitoExtension.class) | ||
public class PolarisDiscoveryHandlerTest { | ||
|
||
private PolarisDiscoveryHandler polarisDiscoveryHandler; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
PolarisDiscoveryProperties polarisDiscoveryProperties = mock(PolarisDiscoveryProperties.class); | ||
doReturn(NAMESPACE_TEST).when(polarisDiscoveryProperties).getNamespace(); | ||
|
||
ConsumerAPI consumerAPI = mock(ConsumerAPI.class); | ||
ServicesResponse servicesResponse = mock(ServicesResponse.class); | ||
doReturn(servicesResponse).when(consumerAPI).getServices(any()); | ||
|
||
PolarisSDKContextManager polarisSDKContextManager = mock(PolarisSDKContextManager.class); | ||
doReturn(consumerAPI).when(polarisSDKContextManager).getConsumerAPI(); | ||
polarisDiscoveryHandler = new PolarisDiscoveryHandler(polarisDiscoveryProperties, polarisSDKContextManager); | ||
} | ||
|
||
@Test | ||
public void testGetServices() throws PolarisException { | ||
ServicesResponse servicesResponse = polarisDiscoveryHandler.getServices(); | ||
assertThat(servicesResponse).isNotNull(); | ||
} | ||
} |