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());
}
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);
}
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;
}
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;
}
Aggregations