use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig in project cloudbreak by hortonworks.
the class DatabaseServerConverter method convert.
public StackDatabaseServerResponse convert(DatabaseServerV4Response databaseServerV4Response) {
StackDatabaseServerResponse stackDatabaseServerResponse = new StackDatabaseServerResponse();
stackDatabaseServerResponse.setCrn(databaseServerV4Response.getCrn());
stackDatabaseServerResponse.setName(databaseServerV4Response.getName());
stackDatabaseServerResponse.setDescription(databaseServerV4Response.getDescription());
stackDatabaseServerResponse.setEnvironmentCrn(databaseServerV4Response.getEnvironmentCrn());
stackDatabaseServerResponse.setHost(databaseServerV4Response.getHost());
stackDatabaseServerResponse.setPort(databaseServerV4Response.getPort());
stackDatabaseServerResponse.setDatabaseVendor(databaseServerV4Response.getDatabaseVendor());
stackDatabaseServerResponse.setDatabaseVendorDisplayName(databaseServerV4Response.getDatabaseVendorDisplayName());
stackDatabaseServerResponse.setCreationDate(databaseServerV4Response.getCreationDate());
if (databaseServerV4Response.getResourceStatus() != null) {
stackDatabaseServerResponse.setResourceStatus(resourceStatusToDatabaseServerResourceStatus(databaseServerV4Response.getResourceStatus()));
}
if (databaseServerV4Response.getStatus() != null) {
stackDatabaseServerResponse.setStatus(statusToDatabaseServerStatus(databaseServerV4Response.getStatus()));
}
stackDatabaseServerResponse.setStatusReason(databaseServerV4Response.getStatusReason());
stackDatabaseServerResponse.setClusterCrn(databaseServerV4Response.getClusterCrn());
if (databaseServerV4Response.getSslConfig() != null) {
SslConfigV4Response sslConfig = databaseServerV4Response.getSslConfig();
DatabaseServerSslConfig databaseServerSslConfig = new DatabaseServerSslConfig();
databaseServerSslConfig.setSslCertificates(sslConfig.getSslCertificates());
if (sslConfig.getSslMode() != null) {
databaseServerSslConfig.setSslMode(sslModeToDatabaseServerSslMode(sslConfig.getSslMode()));
}
if (sslConfig.getSslCertificateType() != null) {
databaseServerSslConfig.setSslCertificateType(sslCertificateTypeToDatabaseServerSslCertificateType(sslConfig.getSslCertificateType()));
}
stackDatabaseServerResponse.setSslConfig(databaseServerSslConfig);
}
return stackDatabaseServerResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig in project cloudbreak by hortonworks.
the class DatabaseServerConverter method convert.
public StackDatabaseServerResponse convert(DatabaseServerV4Response databaseServerV4Response) {
StackDatabaseServerResponse stackDatabaseServerResponse = new StackDatabaseServerResponse();
stackDatabaseServerResponse.setCrn(databaseServerV4Response.getCrn());
stackDatabaseServerResponse.setName(databaseServerV4Response.getName());
stackDatabaseServerResponse.setDescription(databaseServerV4Response.getDescription());
stackDatabaseServerResponse.setEnvironmentCrn(databaseServerV4Response.getEnvironmentCrn());
stackDatabaseServerResponse.setHost(databaseServerV4Response.getHost());
stackDatabaseServerResponse.setPort(databaseServerV4Response.getPort());
stackDatabaseServerResponse.setDatabaseVendor(databaseServerV4Response.getDatabaseVendor());
stackDatabaseServerResponse.setDatabaseVendorDisplayName(databaseServerV4Response.getDatabaseVendorDisplayName());
stackDatabaseServerResponse.setCreationDate(databaseServerV4Response.getCreationDate());
if (databaseServerV4Response.getResourceStatus() != null) {
stackDatabaseServerResponse.setResourceStatus(resourceStatusToDatabaseServerResourceStatus(databaseServerV4Response.getResourceStatus()));
}
if (databaseServerV4Response.getStatus() != null) {
stackDatabaseServerResponse.setStatus(statusToDatabaseServerStatus(databaseServerV4Response.getStatus()));
}
stackDatabaseServerResponse.setStatusReason(databaseServerV4Response.getStatusReason());
stackDatabaseServerResponse.setClusterCrn(databaseServerV4Response.getClusterCrn());
if (databaseServerV4Response.getSslConfig() != null) {
SslConfigV4Response sslConfig = databaseServerV4Response.getSslConfig();
DatabaseServerSslConfig databaseServerSslConfig = new DatabaseServerSslConfig();
databaseServerSslConfig.setSslCertificates(sslConfig.getSslCertificates());
if (sslConfig.getSslMode() != null) {
databaseServerSslConfig.setSslMode(sslModeToDatabaseServerSslMode(sslConfig.getSslMode()));
}
if (sslConfig.getSslCertificateType() != null) {
databaseServerSslConfig.setSslCertificateType(sslCertificateTypeToDatabaseServerSslCertificateType(sslConfig.getSslCertificateType()));
}
stackDatabaseServerResponse.setSslConfig(databaseServerSslConfig);
}
return stackDatabaseServerResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig in project cloudbreak by hortonworks.
the class DatabaseServerConverterTest method testConvertResponse.
@Test
public void testConvertResponse() {
DatabaseServerV4Response source = new DatabaseServerV4Response();
source.setCrn("databaseCrn");
source.setName("databaseName");
source.setDescription("description");
source.setEnvironmentCrn("envCrn");
source.setHost("host");
source.setPort(1234);
source.setDatabaseVendor("vendor");
source.setDatabaseVendorDisplayName("vendorName");
source.setCreationDate(new Date().getTime());
source.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
source.setStatus(Status.AVAILABLE);
source.setStatusReason("Everything is great");
source.setClusterCrn("clusterCrn");
SslConfigV4Response sourceSslConfig = new SslConfigV4Response();
sourceSslConfig.setSslCertificates(Set.of("cert1", "cert2"));
sourceSslConfig.setSslMode(SslMode.ENABLED);
sourceSslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
source.setSslConfig(sourceSslConfig);
StackDatabaseServerResponse result = underTest.convert(source);
assertEquals(source.getCrn(), result.getCrn());
assertEquals(source.getName(), result.getName());
assertEquals(source.getDescription(), result.getDescription());
assertEquals(source.getEnvironmentCrn(), result.getEnvironmentCrn());
assertEquals(source.getHost(), result.getHost());
assertEquals(source.getPort(), result.getPort());
assertEquals(source.getDatabaseVendor(), result.getDatabaseVendor());
assertEquals(source.getDatabaseVendorDisplayName(), result.getDatabaseVendorDisplayName());
assertEquals(source.getCreationDate(), result.getCreationDate());
assertEquals(DatabaseServerResourceStatus.SERVICE_MANAGED, result.getResourceStatus());
assertEquals(DatabaseServerStatus.AVAILABLE, result.getStatus());
assertEquals(source.getStatusReason(), result.getStatusReason());
assertEquals(source.getClusterCrn(), result.getClusterCrn());
DatabaseServerSslConfig resultSslConfig = result.getSslConfig();
assertThat(resultSslConfig.getSslMode()).isEqualTo(DatabaseServerSslMode.ENABLED);
assertThat(resultSslConfig.getSslCertificateType()).isEqualTo(DatabaseServerSslCertificateType.CLOUD_PROVIDER_OWNED);
assertThat(resultSslConfig.getSslCertificates()).isEqualTo(sourceSslConfig.getSslCertificates());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig in project cloudbreak by hortonworks.
the class DatabaseServerConverterTest method testConvertResponse.
@Test
public void testConvertResponse() {
DatabaseServerV4Response source = new DatabaseServerV4Response();
source.setCrn("databaseCrn");
source.setName("databaseName");
source.setDescription("description");
source.setEnvironmentCrn("envCrn");
source.setHost("host");
source.setPort(1234);
source.setDatabaseVendor("vendor");
source.setDatabaseVendorDisplayName("vendorName");
source.setCreationDate(new Date().getTime());
source.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
source.setStatus(Status.AVAILABLE);
source.setStatusReason("Everything is great");
source.setClusterCrn("clusterCrn");
SslConfigV4Response sourceSslConfig = new SslConfigV4Response();
sourceSslConfig.setSslCertificates(Set.of("cert1", "cert2"));
sourceSslConfig.setSslMode(SslMode.ENABLED);
sourceSslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
source.setSslConfig(sourceSslConfig);
StackDatabaseServerResponse result = underTest.convert(source);
assertThat(result.getCrn()).isEqualTo(source.getCrn());
assertThat(result.getName()).isEqualTo(source.getName());
assertThat(result.getDescription()).isEqualTo(source.getDescription());
assertThat(result.getEnvironmentCrn()).isEqualTo(source.getEnvironmentCrn());
assertThat(result.getHost()).isEqualTo(source.getHost());
assertThat(result.getPort()).isEqualTo(source.getPort());
assertThat(result.getDatabaseVendor()).isEqualTo(source.getDatabaseVendor());
assertThat(result.getDatabaseVendorDisplayName()).isEqualTo(source.getDatabaseVendorDisplayName());
assertThat(result.getCreationDate()).isEqualTo(source.getCreationDate());
assertThat(result.getResourceStatus()).isEqualTo(DatabaseServerResourceStatus.SERVICE_MANAGED);
assertThat(result.getStatus()).isEqualTo(DatabaseServerStatus.AVAILABLE);
assertThat(result.getStatusReason()).isEqualTo(source.getStatusReason());
assertThat(result.getClusterCrn()).isEqualTo(source.getClusterCrn());
DatabaseServerSslConfig resultSslConfig = result.getSslConfig();
assertThat(resultSslConfig.getSslMode()).isEqualTo(DatabaseServerSslMode.ENABLED);
assertThat(resultSslConfig.getSslCertificateType()).isEqualTo(DatabaseServerSslCertificateType.CLOUD_PROVIDER_OWNED);
assertThat(resultSslConfig.getSslCertificates()).isEqualTo(sourceSslConfig.getSslCertificates());
}
Aggregations