use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4RequestConverter method convert.
public DatabaseServerV4Request convert(DatabaseServerConfig source) {
DatabaseServerV4Request request = new DatabaseServerV4Request();
request.setName(source.getName());
request.setDescription(source.getDescription());
request.setHost(source.getHost());
request.setPort(source.getPort());
request.setDatabaseVendor(source.getDatabaseVendor().databaseType());
request.setConnectionUserName("REDACTED");
request.setConnectionPassword("REDACTED");
request.setEnvironmentCrn(source.getEnvironmentId());
return request;
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4RequestConverterTest method testConversion.
@Test
public void testConversion() {
DatabaseServerConfig server = new DatabaseServerConfig();
server.setName("myserver");
server.setDescription("mine not yours");
server.setHost("myserver.db.example.com");
server.setPort(5432);
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setConnectionUserName("root");
server.setConnectionPassword("cloudera");
server.setEnvironmentId("myenvironment");
DatabaseServerV4Request request = converter.convert(server);
assertEquals(server.getName(), request.getName());
assertEquals(server.getDescription(), request.getDescription());
assertEquals(server.getHost(), request.getHost());
assertEquals(server.getPort(), request.getPort());
assertEquals(server.getDatabaseVendor().databaseType(), request.getDatabaseVendor());
assertNotEquals(server.getConnectionUserName(), request.getConnectionUserName());
assertNotEquals(server.getConnectionPassword(), request.getConnectionPassword());
assertEquals(server.getEnvironmentId(), request.getEnvironmentCrn());
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request in project cloudbreak by hortonworks.
the class DatabaseServerV4RequestToDatabaseServerConfigConverterTest method testConversion.
@Test
public void testConversion() {
DatabaseServerV4Request request = new DatabaseServerV4Request();
request.setName("myserver");
request.setDescription("mine not yours");
request.setHost("myserver.db.example.com");
request.setPort(5432);
request.setDatabaseVendor("postgres");
request.setConnectionUserName("root");
request.setConnectionPassword("cloudera");
request.setConnectionDriver("org.postgresql.Driver");
request.setEnvironmentCrn("myenvironment");
DatabaseServerConfig server = converter.convert(request);
assertThat(server).isNotNull();
assertThat(server.getName()).isEqualTo(request.getName());
assertThat(server.getDescription()).isEqualTo(request.getDescription());
assertThat(server.getHost()).isEqualTo(request.getHost());
assertThat(server.getPort()).isEqualTo(request.getPort());
assertThat(server.getDatabaseVendor().databaseType()).isEqualTo(request.getDatabaseVendor());
assertThat(server.getConnectionUserName()).isEqualTo(request.getConnectionUserName());
assertThat(server.getConnectionPassword()).isEqualTo(request.getConnectionPassword());
assertThat(server.getConnectionDriver()).isEqualTo(request.getConnectionDriver());
assertThat(server.getEnvironmentId()).isEqualTo(request.getEnvironmentCrn());
assertThat(server.getResourceStatus()).isEqualTo(ResourceStatus.USER_MANAGED);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request in project cloudbreak by hortonworks.
the class DatabaseServerV4ControllerTest method setUp.
@Before
public void setUp() {
initMocks(this);
server = new DatabaseServerConfig();
server.setId(1L);
server.setName(SERVER_NAME);
server.setEnvironmentId(ENVIRONMENT_CRN);
server.setResourceCrn(CRN);
server2 = new DatabaseServerConfig();
server2.setId(2L);
server2.setName("myotherserver");
server2.setEnvironmentId(ENVIRONMENT_CRN);
request = new DatabaseServerV4Request();
request.setName(SERVER_NAME);
serverResponse = new DatabaseServerV4Response();
serverResponse.setId(1L);
serverResponse.setName(SERVER_NAME);
serverResponse2 = new DatabaseServerV4Response();
serverResponse2.setId(2L);
serverResponse2.setName("myotherserver");
allocateRequest = new AllocateDatabaseServerV4Request();
allocateRequest.setClusterCrn(CLUSTER_CRN);
allocateResponse = new DatabaseServerStatusV4Response();
dbStack = new DBStack();
}
Aggregations