DefaultConfigService extends AbstractConfigService { @Override protected Release findLatestActiveRelease(String configAppId, String configClusterName, String configNamespace, ApolloNotificationMessages clientMessages) { return releaseService.findLatestActiveRelease(configAppId, configClusterName, configNamespace); }  @Override void handleMessage(ReleaseMessage message, String channel);  }
@Test public void testLoadConfig() throws Exception { when(releaseService.findLatestActiveRelease(someConfigAppId, someClusterName, defaultNamespaceName)) .thenReturn(someRelease); Release release = configService .loadConfig(someClientAppId, someClientIp, someConfigAppId, someClusterName, defaultNamespaceName, someDataCenter, someNotificationMessages); verify(releaseService, times(1)).findLatestActiveRelease(someConfigAppId, someClusterName, defaultNamespaceName); assertEquals(someRelease, release); }
@Test public void testLoadConfigWithReleaseNotFound() throws Exception { when(releaseService.findLatestActiveRelease(someConfigAppId, someClusterName, defaultNamespaceName)) .thenReturn(null); Release release = configService .loadConfig(someClientAppId, someClientIp, someConfigAppId, someClusterName, defaultNamespaceName, someDataCenter, someNotificationMessages); assertNull(release); }
@Test public void testLoadConfigWithDefaultClusterWithDataCenterRelease() throws Exception { when(releaseService.findLatestActiveRelease(someConfigAppId, someDataCenter, defaultNamespaceName)) .thenReturn(someRelease); Release release = configService .loadConfig(someClientAppId, someClientIp, someConfigAppId, defaultClusterName, defaultNamespaceName, someDataCenter, someNotificationMessages); verify(releaseService, times(1)).findLatestActiveRelease(someConfigAppId, someDataCenter, defaultNamespaceName); assertEquals(someRelease, release); }
@Test public void testLoadConfigWithDefaultClusterWithNoDataCenterRelease() throws Exception { when(releaseService.findLatestActiveRelease(someConfigAppId, someDataCenter, defaultNamespaceName)) .thenReturn(null); when(releaseService.findLatestActiveRelease(someConfigAppId, defaultClusterName, defaultNamespaceName)) .thenReturn(someRelease); Release release = configService .loadConfig(someClientAppId, someClientIp, someConfigAppId, defaultClusterName, defaultNamespaceName, someDataCenter, someNotificationMessages); verify(releaseService, times(1)).findLatestActiveRelease(someConfigAppId, someDataCenter, defaultNamespaceName); verify(releaseService, times(1)) .findLatestActiveRelease(someConfigAppId, defaultClusterName, defaultNamespaceName); assertEquals(someRelease, release); }