use of com.sequenceiq.cloudbreak.api.model.ClusterResponse in project cloudbreak by hortonworks.
the class StackToStackResponseConverterTest method testConvertWithoutNetwork.
@Test
public void testConvertWithoutNetwork() {
// GIVEN
getSource().setNetwork(null);
given(conversionService.convert(any(Object.class), any(Class.class))).willReturn(new ImageJson()).willReturn(new StackAuthenticationResponse()).willReturn(new CredentialResponse()).willReturn(new ClusterResponse()).willReturn(new FailurePolicyResponse()).willReturn(new OrchestratorResponse()).willReturn(new CloudbreakDetailsJson());
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<InstanceGroupRequest>());
// WHEN
StackResponse result = underTest.convert(getSource());
// THEN
assertAllFieldsNotNull(result, Arrays.asList("networkId", "platformVariant", "ambariVersion", "hdpVersion", "network", "flexSubscription"));
}
use of com.sequenceiq.cloudbreak.api.model.ClusterResponse in project cloudbreak by hortonworks.
the class StackToStackResponseConverterTest method testConvertWithoutCredential.
@Test
public void testConvertWithoutCredential() {
// GIVEN
given(conversionService.convert(any(Object.class), any(Class.class))).willReturn(new ImageJson()).willReturn(new StackAuthenticationResponse()).willReturn(new CredentialResponse()).willReturn(new ClusterResponse()).willReturn(new FailurePolicyResponse()).willReturn(new NetworkResponse()).willReturn(new OrchestratorResponse()).willReturn(new CloudbreakDetailsJson());
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<InstanceGroupRequest>());
// WHEN
StackResponse result = underTest.convert(getSource());
// THEN
assertAllFieldsNotNull(result, Arrays.asList("credentialId", "cloudPlatform", "platformVariant", "ambariVersion", "hdpVersion", "stackTemplate", "cloudbreakDetails", "flexSubscription"));
}
use of com.sequenceiq.cloudbreak.api.model.ClusterResponse in project cloudbreak by hortonworks.
the class ClusterV1Controller method getPrivate.
@Override
public ClusterResponse getPrivate(String name) {
IdentityUser user = authenticatedUserService.getCbUser();
Stack stack = stackService.getPrivateStack(name, user);
ClusterResponse cluster = clusterService.retrieveClusterForCurrentUser(stack.getId(), ClusterResponse.class);
String clusterJson = clusterService.getClusterJson(stack.getAmbariIp(), stack.getId());
return clusterService.getClusterResponse(cluster, clusterJson);
}
use of com.sequenceiq.cloudbreak.api.model.ClusterResponse in project cloudbreak by hortonworks.
the class ClusterV1Controller method getPublic.
@Override
public ClusterResponse getPublic(String name) {
IdentityUser user = authenticatedUserService.getCbUser();
Stack stack = stackService.getPublicStack(name, user);
ClusterResponse cluster = clusterService.retrieveClusterForCurrentUser(stack.getId(), ClusterResponse.class);
String clusterJson = clusterService.getClusterJson(stack.getAmbariIp(), stack.getId());
return clusterService.getClusterResponse(cluster, clusterJson);
}
use of com.sequenceiq.cloudbreak.api.model.ClusterResponse in project cloudbreak by hortonworks.
the class StackToStackResponseConverter method convert.
@Override
public StackResponse convert(Stack source) {
StackResponse stackJson = new StackResponse();
try {
Image image = imageService.getImage(source.getId());
stackJson.setImage(getConversionService().convert(image, ImageJson.class));
} catch (CloudbreakImageNotFoundException exc) {
LOGGER.info(exc.getMessage());
}
stackJson.setName(source.getName());
stackJson.setOwner(source.getOwner());
stackJson.setAccount(source.getAccount());
stackJson.setPublicInAccount(source.isPublicInAccount());
stackJson.setStackAuthentication(conversionService.convert(source.getStackAuthentication(), StackAuthenticationResponse.class));
stackJson.setId(source.getId());
if (source.getCredential() == null) {
stackJson.setCloudPlatform(null);
stackJson.setCredentialId(null);
} else {
stackJson.setCloudPlatform(source.cloudPlatform());
stackJson.setCredentialId(source.getCredential().getId());
stackJson.setCredential(getConversionService().convert(source.getCredential(), CredentialResponse.class));
}
stackJson.setStatus(source.getStatus());
stackJson.setStatusReason(source.getStatusReason());
stackJson.setRegion(source.getRegion());
stackJson.setAvailabilityZone(source.getAvailabilityZone());
stackJson.setOnFailureAction(source.getOnFailureActionAction());
List<InstanceGroupResponse> templateGroups = new ArrayList<>(convertInstanceGroups(source.getInstanceGroups()));
stackJson.setInstanceGroups(templateGroups);
if (source.getCluster() != null) {
stackJson.setCluster(getConversionService().convert(source.getCluster(), ClusterResponse.class));
} else {
stackJson.setCluster(new ClusterResponse());
}
if (source.getFailurePolicy() != null) {
stackJson.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(), FailurePolicyResponse.class));
}
if (source.getNetwork() == null) {
stackJson.setNetworkId(null);
} else {
stackJson.setNetworkId(source.getNetwork().getId());
stackJson.setNetwork(getConversionService().convert(source.getNetwork(), NetworkResponse.class));
}
stackJson.setParameters(Maps.newHashMap(source.getParameters()));
stackJson.setPlatformVariant(source.getPlatformVariant());
if (source.getOrchestrator() != null) {
stackJson.setOrchestrator(getConversionService().convert(source.getOrchestrator(), OrchestratorResponse.class));
}
stackJson.setCreated(source.getCreated());
stackJson.setGatewayPort(source.getGatewayPort());
stackJson.setCustomDomain(source.getCustomDomain());
stackJson.setCustomHostname(source.getCustomHostname());
stackJson.setClusterNameAsSubdomain(source.isClusterNameAsSubdomain());
stackJson.setHostgroupNameAsHostname(source.isHostgroupNameAsHostname());
addNodeCount(source, stackJson);
putSubnetIdIntoResponse(source, stackJson);
putVpcIdIntoResponse(source, stackJson);
putS3RoleIntoResponse(source, stackJson);
convertComponentConfig(stackJson, source);
convertTags(stackJson, source.getTags());
addFlexSubscription(stackJson, source);
return stackJson;
}
Aggregations