Search in sources :

Example 11 with BaseParameters

use of com.sequenceiq.environment.parameters.dao.domain.BaseParameters in project cloudbreak by hortonworks.

the class AzureEnvironmentParametersConverterTest method convertTest.

@Test
void convertTest() {
    when(environmentViewConverter.convert(any(Environment.class))).thenReturn(ENVIRONMENT_VIEW);
    ParametersDto parameters = ParametersDto.builder().withId(ID).withAzureParameters(AzureParametersDto.builder().withEncryptionParameters(AzureResourceEncryptionParametersDto.builder().withEncryptionKeyUrl(KEY_URL).withEncryptionKeyResourceGroupName(KEY_RESOURCE_GROUP_NAME).build()).build()).build();
    Environment environment = new Environment();
    environment.setName(ENV_NAME);
    environment.setAccountId(ACCOUNT_ID);
    BaseParameters result = underTest.convert(environment, parameters);
    assertEquals(AzureParameters.class, result.getClass());
    AzureParameters azureResult = (AzureParameters) result;
    assertEquals(ENV_NAME, azureResult.getName());
    assertEquals(ACCOUNT_ID, azureResult.getAccountId());
    assertEquals(ENVIRONMENT_VIEW, azureResult.getEnvironment());
    assertEquals(ID, azureResult.getId());
    assertEquals(KEY_URL, azureResult.getEncryptionKeyUrl());
    assertEquals(KEY_RESOURCE_GROUP_NAME, azureResult.getEncryptionKeyResourceGroupName());
}
Also used : AzureParameters(com.sequenceiq.environment.parameters.dao.domain.AzureParameters) Environment(com.sequenceiq.environment.environment.domain.Environment) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) BaseParameters(com.sequenceiq.environment.parameters.dao.domain.BaseParameters) Test(org.junit.jupiter.api.Test)

Example 12 with BaseParameters

use of com.sequenceiq.environment.parameters.dao.domain.BaseParameters in project cloudbreak by hortonworks.

the class ParametersService method updateResourceGroupName.

public void updateResourceGroupName(Environment environment, String resourceGroupName) {
    if (!CloudPlatform.AZURE.name().equals(environment.getCloudPlatform())) {
        return;
    }
    Optional<BaseParameters> baseParametersOptional = baseParametersRepository.findByEnvironmentId(environment.getId());
    if (baseParametersOptional.isEmpty()) {
        return;
    }
    BaseParameters baseParameters = baseParametersOptional.get();
    AzureParameters azureParameters = (AzureParameters) baseParameters;
    azureParameters.setResourceGroupName(resourceGroupName);
    baseParametersRepository.save(baseParameters);
}
Also used : AzureParameters(com.sequenceiq.environment.parameters.dao.domain.AzureParameters) BaseParameters(com.sequenceiq.environment.parameters.dao.domain.BaseParameters)

Example 13 with BaseParameters

use of com.sequenceiq.environment.parameters.dao.domain.BaseParameters in project cloudbreak by hortonworks.

the class ParametersService method saveParameters.

public BaseParameters saveParameters(Environment environment, ParametersDto parametersDto) {
    BaseParameters savedParameters = null;
    if (parametersDto != null) {
        LOGGER.debug("Saving parameters for environment. Parameters: {}", parametersDto);
        EnvironmentParametersConverter environmentParametersConverter = environmentParamsConverterMap.get(getCloudPlatform(environment));
        if (environmentParametersConverter != null) {
            BaseParameters parameters = environmentParametersConverter.convert(environment, parametersDto);
            parameters.setId(getIfNotNull(parametersDto, ParametersDto::getId));
            parameters.setAccountId(environment.getAccountId());
            savedParameters = save(parameters);
        }
    }
    return savedParameters;
}
Also used : EnvironmentParametersConverter(com.sequenceiq.environment.parameters.v1.converter.EnvironmentParametersConverter) BaseParameters(com.sequenceiq.environment.parameters.dao.domain.BaseParameters)

Example 14 with BaseParameters

use of com.sequenceiq.environment.parameters.dao.domain.BaseParameters in project cloudbreak by hortonworks.

the class BaseEnvironmentParametersConverter method convert.

@Override
public BaseParameters convert(Environment environment, ParametersDto parametersDto) {
    if (parametersDto == null) {
        return null;
    }
    BaseParameters baseParameters = createInstance();
    baseParameters.setId(parametersDto.getId());
    baseParameters.setName(environment.getName());
    baseParameters.setAccountId(environment.getAccountId());
    baseParameters.setEnvironment(environmentViewConverter.convert(environment));
    postConvert(baseParameters, environment, parametersDto);
    return baseParameters;
}
Also used : BaseParameters(com.sequenceiq.environment.parameters.dao.domain.BaseParameters)

Aggregations

BaseParameters (com.sequenceiq.environment.parameters.dao.domain.BaseParameters)14 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)10 Environment (com.sequenceiq.environment.environment.domain.Environment)9 Test (org.junit.jupiter.api.Test)9 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)7 GcpParametersDto (com.sequenceiq.environment.parameter.dto.GcpParametersDto)7 GcpResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto)7 AwsParameters (com.sequenceiq.environment.parameters.dao.domain.AwsParameters)7 AwsParametersDto (com.sequenceiq.environment.parameter.dto.AwsParametersDto)6 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)5 GcpParameters (com.sequenceiq.environment.parameters.dao.domain.GcpParameters)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)2 AzureParameters (com.sequenceiq.environment.parameters.dao.domain.AzureParameters)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)1 AwsDiskEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto)1 AzureParametersDto (com.sequenceiq.environment.parameter.dto.AzureParametersDto)1