ReleaseOpenApiService extends AbstractOpenApiService { public void rollbackRelease(String env, long releaseId, String operator) { checkNotEmpty(env, "Env"); checkNotEmpty(operator, "Operator"); String path = String.format("envs/%s/releases/%s/rollback?operator=%s", escapePath(env), releaseId, escapeParam(operator)); try (CloseableHttpResponse ignored = put(path, null)) { } catch (Throwable ex) { throw new RuntimeException(String.format("Rollback release: %s in env: %s failed", releaseId, 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);  }
@Test public void testRollbackRelease() throws Exception { long someReleaseId = 1L; String someOperator = "someOperator"; final ArgumentCaptor<HttpPut> request = ArgumentCaptor.forClass(HttpPut.class); releaseOpenApiService.rollbackRelease(someEnv, someReleaseId, someOperator); verify(httpClient, times(1)).execute(request.capture()); HttpPut put = request.getValue(); assertEquals( String.format("%s/envs/%s/releases/%s/rollback?operator=%s", someBaseUrl, someEnv, someReleaseId, someOperator), put.getURI().toString()); }
@Test(expected = RuntimeException.class) public void testRollbackReleaseWithError() throws Exception { long someReleaseId = 1L; String someOperator = "someOperator"; when(statusLine.getStatusCode()).thenReturn(400); releaseOpenApiService.rollbackRelease(someEnv, someReleaseId, someOperator); }