@Test public void testUpdateItem() throws Exception { String someKey = "someKey"; String someValue = "someValue"; String someModifiedBy = "someModifiedBy"; OpenItemDTO itemDTO = new OpenItemDTO(); itemDTO.setKey(someKey); itemDTO.setValue(someValue); itemDTO.setDataChangeLastModifiedBy(someModifiedBy); final ArgumentCaptor<HttpPut> request = ArgumentCaptor.forClass(HttpPut.class); itemOpenApiService.updateItem(someAppId, someEnv, someCluster, someNamespace, itemDTO); verify(httpClient, times(1)).execute(request.capture()); HttpPut put = request.getValue(); assertEquals(String .format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", someBaseUrl, someEnv, someAppId, someCluster, someNamespace, someKey), put.getURI().toString()); }
public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Update item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } }
ItemOpenApiService extends AbstractOpenApiService { public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Update item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } }
ItemOpenApiService extends AbstractOpenApiService { public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Update item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } ItemOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); }
ItemOpenApiService extends AbstractOpenApiService { public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Update item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } ItemOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); OpenItemDTO getItem(String appId, String env, String clusterName, String namespaceName, String key); OpenItemDTO createItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO); void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO); void createOrUpdateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO); void removeItem(String appId, String env, String clusterName, String namespaceName, String key, String operator); }
ItemOpenApiService extends AbstractOpenApiService { public void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO) { if (Strings.isNullOrEmpty(clusterName)) { clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT; } if (Strings.isNullOrEmpty(namespaceName)) { namespaceName = ConfigConsts.NAMESPACE_APPLICATION; } checkNotEmpty(appId, "App id"); checkNotEmpty(env, "Env"); checkNotEmpty(itemDTO.getKey(), "Item key"); checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by"); String path = String.format("envs/%s/apps/%s/clusters/%s/namespaces/%s/items/%s", escapePath(env), escapePath(appId), escapePath(clusterName), escapePath(namespaceName), escapePath(itemDTO.getKey())); try (CloseableHttpResponse ignored = put(path, itemDTO)) { } catch (Throwable ex) { throw new RuntimeException(String .format("Update item: %s for appId: %s, cluster: %s, namespace: %s in env: %s failed", itemDTO.getKey(), appId, clusterName, namespaceName, env), ex); } } ItemOpenApiService(CloseableHttpClient client, String baseUrl, Gson gson); OpenItemDTO getItem(String appId, String env, String clusterName, String namespaceName, String key); OpenItemDTO createItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO); void updateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO); void createOrUpdateItem(String appId, String env, String clusterName, String namespaceName, OpenItemDTO itemDTO); void removeItem(String appId, String env, String clusterName, String namespaceName, String key, String operator);  }