### Question:
ClusterRestClient extends RestClient implements ClusterClient { @Override public String createCluster(ClusterCreateRequest clusterCreateRequest) throws IOException { Preconditions.checkArgument(clusterCreateRequest != null, "ClusterCreateRequest object couldn't be null."); HttpPost postRequest = new HttpPost(resolveURL("/clusters")); addRequestBody(postRequest, clusterCreateRequest); CloseableHttpResponse httpResponse = execute(postRequest); String newClusterId; try { RestClient.analyzeResponseCode(httpResponse); JsonObject jsonContent = new JsonParser().parse(EntityUtils.toString(httpResponse.getEntity(), Charsets.UTF_8)).getAsJsonObject(); newClusterId = jsonContent.get(CLUSTER_ID_ATTRIBUTE_NAME).getAsString(); } finally { httpResponse.close(); } return newClusterId; } ClusterRestClient(Supplier<RestClientConnectionConfig> config, CloseableHttpClient httpClient);  ClusterRestClient(Supplier<RestClientConnectionConfig> config, CloseableHttpClient httpClient, Gson gson); @Override List<ClusterSummary> getClusters(); @Override ClusterDetails getCluster(String clusterId); @Override void deleteCluster(String clusterId); @Override void deleteCluster(String clusterId, ClusterOperationRequest clusterOperationRequest); @Override String createCluster(ClusterCreateRequest clusterCreateRequest); @Override ClusterStatusResponse getClusterStatus(String clusterId); @Override JsonObject getClusterConfig(String clusterId); @Override void setClusterConfig(String clusterId, ClusterConfigureRequest clusterConfigureRequest); @Override List<String> getClusterServices(String clusterId); @Override void syncClusterTemplate(String clusterId); @Override void setClusterExpireTime(String clusterId, long expireTime); @Override void startServiceOnCluster(String clusterId, String serviceId); @Override void startServiceOnCluster(String clusterId, String serviceId,
                                    ClusterOperationRequest clusterOperationRequest); @Override void stopServiceOnCluster(String clusterId, String serviceId); @Override void stopServiceOnCluster(String clusterId, String serviceId, ClusterOperationRequest clusterOperationRequest); @Override void restartServiceOnCluster(String clusterId, String serviceId); @Override void restartServiceOnCluster(String clusterId, String serviceId,
                                      ClusterOperationRequest clusterOperationRequest); @Override void addServicesOnCluster(String clusterId, AddServicesRequest addServicesRequest);  }### Answer:
@Test public void testCreateClusterSuccess() throws IOException { ClusterCreateRequest createRequest = ClusterCreateRequest.builder() .setName(EXPECTED_NEW_CLUSTER_NAME) .setClusterTemplateName(Entities.ClusterTemplateExample.REACTOR.toString()) .setNumMachines(10) .setDNSSuffix("ro.test.com") .build(); String newClusterId = clusterClient.createCluster(createRequest); assertEquals("testCluster", newClusterId); }
@Test public void testCreateClusterFailed() throws IOException { ClusterCreateRequest createRequest = ClusterCreateRequest.builder() .setName("Unexpected") .setClusterTemplateName(Entities.ClusterTemplateExample.REACTOR.toString()) .setNumMachines(10) .setDNSSuffix("ro.test.com") .build(); try { clusterClient.createCluster(createRequest); Assert.fail("Expected HttpFailureException"); } catch (HttpFailureException e) { Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, e.getStatusCode()); } }