use of com.ctrip.framework.apollo.openapi.dto.OpenClusterDTO in project apollo by ctripcorp.
the class ServerClusterOpenApiService method createCluster.
@Override
public OpenClusterDTO createCluster(String env, OpenClusterDTO openClusterDTO) {
ClusterDTO toCreate = OpenApiBeanUtils.transformToClusterDTO(openClusterDTO);
ClusterDTO createdClusterDTO = clusterService.createCluster(Env.valueOf(env), toCreate);
return OpenApiBeanUtils.transformFromClusterDTO(createdClusterDTO);
}
use of com.ctrip.framework.apollo.openapi.dto.OpenClusterDTO in project apollo by ctripcorp.
the class ClusterOpenApiServiceTest method testCreateClusterWithError.
@Test(expected = RuntimeException.class)
public void testCreateClusterWithError() throws Exception {
String someCluster = "someCluster";
String someCreatedBy = "someCreatedBy";
OpenClusterDTO clusterDTO = new OpenClusterDTO();
clusterDTO.setAppId(someAppId);
clusterDTO.setName(someCluster);
clusterDTO.setDataChangeCreatedBy(someCreatedBy);
when(statusLine.getStatusCode()).thenReturn(400);
clusterOpenApiService.createCluster(someEnv, clusterDTO);
}
use of com.ctrip.framework.apollo.openapi.dto.OpenClusterDTO in project apollo by ctripcorp.
the class ClusterOpenApiServiceTest method testCreateCluster.
@Test
public void testCreateCluster() throws Exception {
String someCluster = "someCluster";
String someCreatedBy = "someCreatedBy";
OpenClusterDTO clusterDTO = new OpenClusterDTO();
clusterDTO.setAppId(someAppId);
clusterDTO.setName(someCluster);
clusterDTO.setDataChangeCreatedBy(someCreatedBy);
final ArgumentCaptor<HttpPost> request = ArgumentCaptor.forClass(HttpPost.class);
clusterOpenApiService.createCluster(someEnv, clusterDTO);
verify(httpClient, times(1)).execute(request.capture());
HttpPost post = request.getValue();
assertEquals(String.format("%s/envs/%s/apps/%s/clusters", someBaseUrl, someEnv, someAppId), post.getURI().toString());
StringEntity entity = (StringEntity) post.getEntity();
assertEquals(ContentType.APPLICATION_JSON.toString(), entity.getContentType().getValue());
assertEquals(gson.toJson(clusterDTO), EntityUtils.toString(entity));
}
Aggregations