From fe2155b57cba684285868a1933b531c3de14d749 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Mon, 14 Nov 2022 10:16:55 +0800 Subject: [PATCH] fix:fix discovery junit. (#725) --- CHANGELOG.md | 1 + .../cloud/polaris/discovery/PolarisDiscoveryClientTest.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 996ab409b..67ce1b663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,3 +13,4 @@ - [Test: remote deprecated method in test](https://github.com/Tencent/spring-cloud-tencent/pull/706) - [docs:update README.](https://github.com/Tencent/spring-cloud-tencent/pull/718) - [Code optimization & correct comment](https://github.com/Tencent/spring-cloud-tencent/pull/722) +- [fix:fix discovery junit.](https://github.com/Tencent/spring-cloud-tencent/pull/725) diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryClientTest.java b/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryClientTest.java index 303f39736..41da53413 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryClientTest.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryClientTest.java @@ -32,6 +32,7 @@ import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -63,7 +64,8 @@ public class PolarisDiscoveryClientTest { @Test public void testGetServices() { - when(polarisServiceDiscovery.getServices()).thenReturn(singletonList(SERVICE_PROVIDER)); +// when(polarisServiceDiscovery.getServices()).thenReturn(singletonList(SERVICE_PROVIDER)); + doReturn(singletonList(SERVICE_PROVIDER)).when(polarisServiceDiscovery).getServices(); List services = client.getServices();