use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.responses.DatabaseV4Response in project cloudbreak by hortonworks.
the class DatabaseV4ControllerTest method testRegister.
@Test
public void testRegister() {
when(databaseV4RequestToDatabaseConfigConverter.convert(any())).thenReturn(db);
when(service.register(db, false)).thenReturn(db);
when(databaseConfigToDatabaseV4ResponseConverter.convert(db)).thenReturn(response);
DatabaseV4Response response = underTest.register(request);
assertEquals(db.getName(), response.getName());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.responses.DatabaseV4Response in project cloudbreak by hortonworks.
the class DatabaseConfigToDatabaseV4ResponseConverterTest method testConvert.
@Test
public void testConvert() {
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setName(NAME);
databaseConfig.setResourceCrn(CRN);
databaseConfig.setDescription(DESCRIPTION);
databaseConfig.setCreationDate(CREATION_DATE);
databaseConfig.setConnectionDriver(CONNECTION_DRIVER);
databaseConfig.setConnectionUserName("userName");
databaseConfig.setConnectionPassword("password");
databaseConfig.setConnectionURL(CONNECTION_URL);
databaseConfig.setDatabaseVendor(DatabaseVendor.MYSQL);
databaseConfig.setType(TYPE);
databaseConfig.setEnvironmentId(ENVIRONMENT_CRN);
databaseConfig.setStatus(ResourceStatus.SERVICE_MANAGED);
when(stringToSecretResponseConverter.convert(any())).thenReturn(new SecretResponse());
DatabaseV4Response response = underTest.convert(databaseConfig);
assertEquals(NAME, response.getName());
assertEquals(CRN.toString(), response.getCrn());
assertEquals(DESCRIPTION, response.getDescription());
assertEquals(CREATION_DATE, response.getCreationDate().longValue());
assertEquals(CONNECTION_DRIVER, response.getConnectionDriver());
assertNotNull(response.getConnectionPassword());
assertNotNull(response.getConnectionUserName());
assertEquals(CONNECTION_URL, response.getConnectionURL());
assertEquals(DatabaseVendor.MYSQL.name(), response.getDatabaseEngine());
assertEquals(TYPE, response.getType());
assertEquals(ENVIRONMENT_CRN, response.getEnvironmentCrn());
assertEquals(ResourceStatus.SERVICE_MANAGED, response.getResourceStatus());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.responses.DatabaseV4Response in project cloudbreak by hortonworks.
the class DatabaseConfigToDatabaseV4ResponseConverter method convert.
public DatabaseV4Response convert(DatabaseConfig source) {
DatabaseV4Response json = new DatabaseV4Response();
json.setName(source.getName());
json.setCrn(source.getResourceCrn().toString());
json.setDescription(source.getDescription());
json.setConnectionURL(source.getConnectionURL());
json.setDatabaseEngine(source.getDatabaseVendor().name());
json.setConnectionDriver(source.getConnectionDriver());
json.setConnectionUserName(stringToSecretResponseConverter.convert(source.getConnectionUserName().getSecret()));
json.setConnectionPassword(stringToSecretResponseConverter.convert(source.getConnectionPassword().getSecret()));
json.setDatabaseEngineDisplayName(source.getDatabaseVendor().displayName());
json.setCreationDate(source.getCreationDate());
json.setEnvironmentCrn(source.getEnvironmentId());
json.setType(source.getType());
json.setResourceStatus(source.getStatus());
return json;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.responses.DatabaseV4Response in project cloudbreak by hortonworks.
the class RDSConfigToDatabaseV4ResponseConverter method convert.
public DatabaseV4Response convert(RDSConfig source) {
DatabaseV4Response json = new DatabaseV4Response();
json.setId(source.getId());
json.setName(source.getName());
json.setDescription(source.getDescription());
json.setConnectionURL(source.getConnectionURL());
json.setDatabaseEngine(source.getDatabaseEngine().name());
json.setConnectionDriver(source.getConnectionDriver());
json.setConnectionUserName(stringToSecretResponseConverter.convert(source.getConnectionUserNameSecret()));
json.setConnectionPassword(stringToSecretResponseConverter.convert(source.getConnectionPasswordSecret()));
json.setDatabaseEngineDisplayName(source.getDatabaseEngine().displayName());
json.setCreationDate(source.getCreationDate());
json.setClusterNames(clusterService.findNamesByRdsConfig(source.getId()));
json.setType(source.getType());
json.setWorkspace(workspaceToWorkspaceResourceV4ResponseConverter.convert(source.getWorkspace()));
return json;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.database.responses.DatabaseV4Response in project cloudbreak by hortonworks.
the class DatabaseV4ControllerTest method setUp.
@Before
public void setUp() {
initMocks(this);
db = new DatabaseConfig();
db.setId(1L);
db.setName(DB_NAME);
db.setResourceCrn(CRN);
db2 = new DatabaseConfig();
db2.setId(2L);
db2.setName("myotherdb");
request = new DatabaseV4Request();
request.setName(DB_NAME);
response = new DatabaseV4Response();
response.setName(DB_NAME);
response2 = new DatabaseV4Response();
response2.setName("myotherdb");
}
Aggregations