use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class AmbariDatabaseMapperTest method testMapAmbariDatabaseDetailsJsonToRdsConfig.
@Test
public void testMapAmbariDatabaseDetailsJsonToRdsConfig() {
RDSConfig rdsConfig = mapper.mapAmbariDatabaseDetailsJsonToRdsConfig(json, cluster, null, false);
assertEquals(mapper.mapName(null, cluster), rdsConfig.getName());
assertEquals(mapper.mapConnectionUrl(json), rdsConfig.getConnectionURL());
assertEquals(ResourceStatus.USER_MANAGED, rdsConfig.getStatus());
assertEquals(RdsType.AMBARI.name(), rdsConfig.getType());
assertEquals("org.postgresql.Driver", rdsConfig.getConnectionDriver());
assertNull(rdsConfig.getId());
assertNull(rdsConfig.getClusters());
assertNull(rdsConfig.getStackVersion());
assertNotNull(rdsConfig.getCreationDate());
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverterTest method mysqlJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnMysqlVendorProperties.
@Test
public void mysqlJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnMysqlVendorProperties() {
RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
rdsConfigRequest.setConnectionURL("jdbc:mysql://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.MYSQL.connectionDriver(), rdsConfig.getConnectionDriver());
Assert.assertEquals(DatabaseVendor.MYSQL.name(), rdsConfig.getDatabaseEngine());
verify(missingResourceNameGenerator, times(0)).generateName(any(APIResourceType.class));
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class TestUtil method rdsConfig.
public static RDSConfig rdsConfig(RdsType rdsType) {
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setName(rdsType.name());
rdsConfig.setConnectionPassword("iamsoosecure");
rdsConfig.setConnectionUserName("heyitsme");
rdsConfig.setConnectionURL("jdbc:postgresql://10.1.1.1:5432/" + rdsType.name().toLowerCase());
rdsConfig.setType(rdsType.name());
rdsConfig.setConnectionDriver("org.postgresql.Driver");
rdsConfig.setDatabaseEngine(DatabaseVendor.POSTGRES.name());
return rdsConfig;
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class AmbariDatabaseMapperImpl method mapAmbariDatabaseDetailsJsonToRdsConfig.
@Override
public RDSConfig mapAmbariDatabaseDetailsJsonToRdsConfig(AmbariDatabaseDetailsJson ambariDatabaseDetailsJson, Cluster cluster, Stack stack, boolean publicInAccount) {
if (ambariDatabaseDetailsJson == null && cluster == null) {
return null;
}
RDSConfig rDSConfig = new RDSConfig();
if (ambariDatabaseDetailsJson != null) {
rDSConfig.setConnectionUserName(ambariDatabaseDetailsJson.getUserName());
if (ambariDatabaseDetailsJson.getVendor() != null) {
rDSConfig.setDatabaseEngine(ambariDatabaseDetailsJson.getVendor().name());
}
rDSConfig.setConnectionURL(mapConnectionUrl(ambariDatabaseDetailsJson));
rDSConfig.setConnectionPassword(ambariDatabaseDetailsJson.getPassword());
}
if (cluster != null) {
rDSConfig.setName(mapName(stack, cluster));
rDSConfig.setAccount(cluster.getAccount());
rDSConfig.setOwner(cluster.getOwner());
}
rDSConfig.setPublicInAccount(publicInAccount);
rDSConfig.setCreationDate(new java.util.Date().getTime());
rDSConfig.setType(com.sequenceiq.cloudbreak.api.model.rds.RdsType.AMBARI.name());
rDSConfig.setConnectionDriver("org.postgresql.Driver");
rDSConfig.setStatus(com.sequenceiq.cloudbreak.api.model.ResourceStatus.USER_MANAGED);
return rDSConfig;
}
use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.
the class ClusterToClusterDetailsConverter method addDatabaseInfo.
private void addDatabaseInfo(ClusterDetails clusterDetails, Cluster source) {
RDSConfig rdsConfig = rdsConfigService.findByClusterIdAndType(source.getOwner(), source.getAccount(), source.getId(), RdsType.AMBARI);
if (rdsConfig == null || DatabaseVendor.EMBEDDED.name().equalsIgnoreCase(rdsConfig.getDatabaseEngine())) {
clusterDetails.setDatabaseType(DatabaseVendor.EMBEDDED.name());
clusterDetails.setExternalDatabase(Boolean.FALSE);
} else {
clusterDetails.setDatabaseType(rdsConfig.getDatabaseEngine());
clusterDetails.setExternalDatabase(Boolean.TRUE);
}
}
Aggregations