use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class ClusterDecorator method prepareRds.
private void prepareRds(Cluster subject, IdentityUser user, ClusterRequest request, Stack stack) {
subject.setRdsConfigs(new HashSet<>());
if (request.getRdsConfigIds() != null) {
for (Long rdsConfigId : request.getRdsConfigIds()) {
RDSConfig rdsConfig = rdsConfigService.get(rdsConfigId);
subject.getRdsConfigs().add(rdsConfig);
}
}
if (request.getRdsConfigJsons() != null) {
for (RDSConfigRequest requestRdsConfig : request.getRdsConfigJsons()) {
RDSConfig rdsConfig = conversionService.convert(requestRdsConfig, RDSConfig.class);
rdsConfig.setPublicInAccount(stack.isPublicInAccount());
rdsConfig = rdsConfigService.createIfNotExists(user, rdsConfig);
subject.getRdsConfigs().add(rdsConfig);
}
}
Optional.of(request.getRdsConfigNames()).ifPresent(confs -> confs.forEach(confName -> subject.getRdsConfigs().add(rdsConfigService.getPublicRdsConfig(confName, user))));
if (request.getAmbariDatabaseDetails() != null) {
RDSConfig rdsConfig = ambariDatabaseMapper.mapAmbariDatabaseDetailsJsonToRdsConfig(request.getAmbariDatabaseDetails(), subject, stack, stack.isPublicInAccount());
subject.getRdsConfigs().add(rdsConfigService.createIfNotExists(user, rdsConfig));
}
ambariConfigurationService.createDefaultRdsConfigIfNeeded(stack, subject).ifPresent(rdsConfig -> subject.getRdsConfigs().add(rdsConfig));
}
use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverterTest method testConverterWhenNameIsNullThenShouldReturnGeneratedName.
@Test
public void testConverterWhenNameIsNullThenShouldReturnGeneratedName() {
RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
rdsConfigRequest.setName(null);
RDSConfig rdsConfig = underTest.convert(rdsConfigRequest);
Assert.assertEquals(rdsConfigRequest.getConnectionPassword(), rdsConfig.getConnectionPassword());
Assert.assertEquals(rdsConfigRequest.getConnectionUserName(), rdsConfig.getConnectionUserName());
Assert.assertEquals(rdsConfigRequest.getConnectionURL(), rdsConfig.getConnectionURL());
Assert.assertEquals(rdsConfigRequest.getType(), rdsConfig.getType());
Assert.assertEquals(NAME, rdsConfig.getName());
Assert.assertEquals(DatabaseVendor.POSTGRES.connectionDriver(), rdsConfig.getConnectionDriver());
Assert.assertEquals(DatabaseVendor.POSTGRES.name(), rdsConfig.getDatabaseEngine());
verify(missingResourceNameGenerator, times(1)).generateName(any(APIResourceType.class));
}
use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverterTest method postgresJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnPostgresVendorProperties.
@Test
public void postgresJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnPostgresVendorProperties() {
RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
rdsConfigRequest.setConnectionURL("jdbc:postgresql://test.eu-west-1.rds.amazonaws.com:5432/test");
RDSConfig rdsConfig = underTest.convert(rdsConfigRequest);
Assert.assertEquals(rdsConfigRequest.getConnectionPassword(), rdsConfig.getConnectionPassword());
Assert.assertEquals(rdsConfigRequest.getConnectionUserName(), rdsConfig.getConnectionUserName());
Assert.assertEquals(rdsConfigRequest.getConnectionURL(), rdsConfig.getConnectionURL());
Assert.assertEquals(rdsConfigRequest.getType(), rdsConfig.getType());
Assert.assertEquals(rdsConfigRequest.getName(), rdsConfig.getName());
Assert.assertEquals(DatabaseVendor.POSTGRES.connectionDriver(), rdsConfig.getConnectionDriver());
Assert.assertEquals(DatabaseVendor.POSTGRES.name(), rdsConfig.getDatabaseEngine());
verify(missingResourceNameGenerator, times(0)).generateName(any(APIResourceType.class));
}
use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverterTest method unsupportedJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnBadRequestException.
@Test
public void unsupportedJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnBadRequestException() {
RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
rdsConfigRequest.setConnectionURL("jdbc:smalldog://test.eu-west-1.rds.amazonaws.com:5432/test");
thrown.expect(BadRequestException.class);
underTest.convert(rdsConfigRequest);
verify(missingResourceNameGenerator, times(0)).generateName(any(APIResourceType.class));
}
Aggregations