@Test public void testGetLatestActiveRelease() throws Exception { final ArgumentCaptor<HttpGet> request = ArgumentCaptor.forClass(HttpGet.class); releaseOpenApiService.getLatestActiveRelease(someAppId, someEnv, someCluster, someNamespace); verify(httpClient, times(1)).execute(request.capture()); HttpGet get = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/releases/latest", someBaseUrl, someEnv, someAppId, someCluster, someNamespace), get.getURI().toString()); }
public OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/releases/latest", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenReleaseDTO.class); } catch (Throwable ex) { throw new RuntimeException(String .format("Get latest active release for appId: %s, cluster: %s, namespace: %s in env: %s failed", appId, clusterName, namespaceName, env), ex); } }
ReleaseOpenApiService extends AbstractOpenApiService { public OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/releases/latest", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenReleaseDTO.class); } catch (Throwable ex) { throw new RuntimeException(String .format("Get latest active release for appId: %s, cluster: %s, namespace: %s in env: %s failed", appId, clusterName, namespaceName, env), ex); } } }
ReleaseOpenApiService extends AbstractOpenApiService { public OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/releases/latest", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenReleaseDTO.class); } catch (Throwable ex) { throw new RuntimeException(String .format("Get latest active release for appId: %s, cluster: %s, namespace: %s in env: %s failed", appId, clusterName, namespaceName, env), ex); } } ReleaseOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); }
ReleaseOpenApiService extends AbstractOpenApiService { public OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/releases/latest", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenReleaseDTO.class); } catch (Throwable ex) { throw new RuntimeException(String .format("Get latest active release for appId: %s, cluster: %s, namespace: %s in env: %s failed", appId, clusterName, namespaceName, env), ex); } } ReleaseOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); OpenReleaseDTO publishNamespace(String appId, String env, String clusterName, String namespaceName,
      NamespaceReleaseDTO releaseDTO); OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName); void rollbackRelease(String env, long releaseId, String operator); }
ReleaseOpenApiService extends AbstractOpenApiService { public OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/releases/latest", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName)); try (CloseableHttpResponse response = get(path)) { return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenReleaseDTO.class); } catch (Throwable ex) { throw new RuntimeException(String .format("Get latest active release for appId: %s, cluster: %s, namespace: %s in env: %s failed", appId, clusterName, namespaceName, env), ex); } } ReleaseOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); OpenReleaseDTO publishNamespace(String appId, String env, String clusterName, String namespaceName,
      NamespaceReleaseDTO releaseDTO); OpenReleaseDTO getLatestActiveRelease(String appId, String env, String clusterName, String namespaceName); void rollbackRelease(String env, long releaseId, String operator);  }