Search in sources :

Example 1 with CredentialResponse

use of com.sequenceiq.cloudbreak.api.model.CredentialResponse 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"));
}
Also used : InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) CloudbreakDetailsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson) ClusterResponse(com.sequenceiq.cloudbreak.api.model.ClusterResponse) CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse) OrchestratorResponse(com.sequenceiq.cloudbreak.api.model.OrchestratorResponse) FailurePolicyResponse(com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) ImageJson(com.sequenceiq.cloudbreak.api.model.ImageJson) StackAuthenticationResponse(com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Test(org.junit.Test)

Example 2 with CredentialResponse

use of com.sequenceiq.cloudbreak.api.model.CredentialResponse 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"));
}
Also used : InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) CloudbreakDetailsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson) ClusterResponse(com.sequenceiq.cloudbreak.api.model.ClusterResponse) CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse) OrchestratorResponse(com.sequenceiq.cloudbreak.api.model.OrchestratorResponse) FailurePolicyResponse(com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) ImageJson(com.sequenceiq.cloudbreak.api.model.ImageJson) NetworkResponse(com.sequenceiq.cloudbreak.api.model.NetworkResponse) StackAuthenticationResponse(com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Test(org.junit.Test)

Example 3 with CredentialResponse

use of com.sequenceiq.cloudbreak.api.model.CredentialResponse in project cloudbreak by hortonworks.

the class CredentialToCredentialResponseConverter method convert.

@Override
public CredentialResponse convert(Credential source) {
    CredentialResponse credentialJson = new CredentialResponse();
    credentialJson.setId(source.getId());
    credentialJson.setCloudPlatform(source.cloudPlatform());
    credentialJson.setName(source.getName());
    credentialJson.setPublicInAccount(source.isPublicInAccount());
    if (source.getAttributes() != null) {
        Map<String, Object> parameters = credentialDefinitionService.revertAndRemoveProperties(platform(source.cloudPlatform()), source.getAttributes().getMap());
        credentialJson.setParameters(parameters);
    }
    credentialJson.setDescription(source.getDescription() == null ? "" : source.getDescription());
    if (source.getTopology() != null) {
        credentialJson.setTopologyId(source.getTopology().getId());
    }
    coverSensitiveData(credentialJson);
    return credentialJson;
}
Also used : CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse)

Example 4 with CredentialResponse

use of com.sequenceiq.cloudbreak.api.model.CredentialResponse in project cloudbreak by hortonworks.

the class UserProfileToUserProfileResponseConverter method convert.

@Override
public UserProfileResponse convert(UserProfile entity) {
    UserProfileResponse userProfileResponse = new UserProfileResponse();
    userProfileResponse.setAccount(entity.getAccount());
    userProfileResponse.setOwner(entity.getOwner());
    if (entity.getCredential() != null) {
        CredentialResponse credentialResponse = getConversionService().convert(entity.getCredential(), CredentialResponse.class);
        userProfileResponse.setCredential(credentialResponse);
    }
    Map<String, Object> map = entity.getUiProperties().getMap();
    userProfileResponse.setUiProperties(map == null ? new HashMap<>() : map);
    return userProfileResponse;
}
Also used : UserProfileResponse(com.sequenceiq.cloudbreak.api.model.UserProfileResponse) HashMap(java.util.HashMap) CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse)

Example 5 with CredentialResponse

use of com.sequenceiq.cloudbreak.api.model.CredentialResponse in project cloudbreak by hortonworks.

the class StackToStackResponseConverterTest method testConvertWithoutFailurePolicy.

@Test
public void testConvertWithoutFailurePolicy() {
    // GIVEN
    getSource().setFailurePolicy(null);
    given(conversionService.convert(any(Object.class), any(Class.class))).willReturn(new ImageJson()).willReturn(new StackAuthenticationResponse()).willReturn(new CredentialResponse()).willReturn(new ClusterResponse()).willReturn(new NetworkResponse()).willReturn(new OrchestratorResponse()).willReturn(new CloudbreakDetailsJson()).willReturn(new CredentialResponse()).willReturn(new NetworkResponse());
    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("failurePolicy", "platformVariant", "ambariVersion", "hdpVersion", "stackTemplate", "cloudbreakDetails", "flexSubscription"));
}
Also used : InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) CloudbreakDetailsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson) ClusterResponse(com.sequenceiq.cloudbreak.api.model.ClusterResponse) CredentialResponse(com.sequenceiq.cloudbreak.api.model.CredentialResponse) OrchestratorResponse(com.sequenceiq.cloudbreak.api.model.OrchestratorResponse) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) ImageJson(com.sequenceiq.cloudbreak.api.model.ImageJson) NetworkResponse(com.sequenceiq.cloudbreak.api.model.NetworkResponse) StackAuthenticationResponse(com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Test(org.junit.Test)

Aggregations

CredentialResponse (com.sequenceiq.cloudbreak.api.model.CredentialResponse)7 CloudbreakDetailsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson)5 ImageJson (com.sequenceiq.cloudbreak.api.model.ImageJson)5 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)5 OrchestratorResponse (com.sequenceiq.cloudbreak.api.model.OrchestratorResponse)5 StackAuthenticationResponse (com.sequenceiq.cloudbreak.api.model.StackAuthenticationResponse)5 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)5 Test (org.junit.Test)5 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)5 ClusterResponse (com.sequenceiq.cloudbreak.api.model.ClusterResponse)4 FailurePolicyResponse (com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse)4 NetworkResponse (com.sequenceiq.cloudbreak.api.model.NetworkResponse)4 UserProfileResponse (com.sequenceiq.cloudbreak.api.model.UserProfileResponse)1 HashMap (java.util.HashMap)1