AppOpenApiService extends AbstractOpenApiService { public List<OpenEnvClusterDTO> getEnvClusterInfo(String appId) { checkNotEmpty(appId, "App id"); String path = String.format("apps/%s/envclusters", escapePath(appId)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_ENV_CLUSTER_DTO_LIST_TYPE); } catch (Throwable ex) { throw new RuntimeException(String.format("Load env cluster information for appId: %s failed", appId), ex); } } AppOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); List<OpenEnvClusterDTO> getEnvClusterInfo(String appId); List<OpenAppDTO> getAppsInfo(List<String> appIds);  }
@Test public void testGetEnvClusterInfo() throws Exception { final ArgumentCaptor<HttpGet> request = ArgumentCaptor.forClass(HttpGet.class); appOpenApiService.getEnvClusterInfo(someAppId); verify(httpClient, times(1)).execute(request.capture()); HttpGet get = request.getValue(); assertEquals(String .format("%s/apps/%s/envclusters", someBaseUrl, someAppId), get.getURI().toString()); }
@Test(expected = RuntimeException.class) public void testGetEnvClusterInfoWithError() throws Exception { when(statusLine.getStatusCode()).thenReturn(500); appOpenApiService.getEnvClusterInfo(someAppId); }