@Test(expected = RuntimeException.class) public void testGetNamespacesWithError() throws Exception { when(statusLine.getStatusCode()).thenReturn(404); namespaceOpenApiService.getNamespaces(someAppId, someEnv, someCluster); }
public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces", escapePath(env), escapePath(appId), escapePath(clusterName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_NAMESPACE_DTO_LIST_TYPE); } catch (Throwable ex) { throw new RuntimeException(String .format("Get namespaces for appId: %s, cluster: %s in env: %s failed", appId, clusterName, env), ex); } }
NamespaceOpenApiService extends AbstractOpenApiService { public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces", escapePath(env), escapePath(appId), escapePath(clusterName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_NAMESPACE_DTO_LIST_TYPE); } catch (Throwable ex) { throw new RuntimeException(String .format("Get namespaces for appId: %s, cluster: %s in env: %s failed", appId, clusterName, env), ex); } } }
NamespaceOpenApiService extends AbstractOpenApiService { public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces", escapePath(env), escapePath(appId), escapePath(clusterName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_NAMESPACE_DTO_LIST_TYPE); } catch (Throwable ex) { throw new RuntimeException(String .format("Get namespaces for appId: %s, cluster: %s in env: %s failed", appId, clusterName, env), ex); } } NamespaceOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); }
NamespaceOpenApiService extends AbstractOpenApiService { public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces", escapePath(env), escapePath(appId), escapePath(clusterName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_NAMESPACE_DTO_LIST_TYPE); } catch (Throwable ex) { throw new RuntimeException(String .format("Get namespaces for appId: %s, cluster: %s in env: %s failed", appId, clusterName, env), ex); } } NamespaceOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName); List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName); OpenAppNamespaceDTO createAppNamespace(OpenAppNamespaceDTO appNamespaceDTO); OpenNamespaceLockDTO getNamespaceLock(String appId, String env, String clusterName, String namespaceName); }
NamespaceOpenApiService extends AbstractOpenApiService { public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces", escapePath(env), escapePath(appId), escapePath(clusterName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_NAMESPACE_DTO_LIST_TYPE); } catch (Throwable ex) { throw new RuntimeException(String .format("Get namespaces for appId: %s, cluster: %s in env: %s failed", appId, clusterName, env), ex); } } NamespaceOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName); List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName); OpenAppNamespaceDTO createAppNamespace(OpenAppNamespaceDTO appNamespaceDTO); OpenNamespaceLockDTO getNamespaceLock(String appId, String env, String clusterName, String namespaceName);  }