Search in sources :

Example 1 with DatabaseV4Response

use of com.sequenceiq.redbeams.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());
}
Also used : DatabaseV4Response(com.sequenceiq.redbeams.api.endpoint.v4.database.responses.DatabaseV4Response) Test(org.junit.Test)

Example 2 with DatabaseV4Response

use of com.sequenceiq.redbeams.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());
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) DatabaseV4Response(com.sequenceiq.redbeams.api.endpoint.v4.database.responses.DatabaseV4Response) DatabaseConfig(com.sequenceiq.redbeams.domain.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 3 with DatabaseV4Response

use of com.sequenceiq.redbeams.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;
}
Also used : DatabaseV4Response(com.sequenceiq.redbeams.api.endpoint.v4.database.responses.DatabaseV4Response)

Example 4 with DatabaseV4Response

use of com.sequenceiq.redbeams.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;
}
Also used : DatabaseV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.database.responses.DatabaseV4Response)

Example 5 with DatabaseV4Response

use of com.sequenceiq.redbeams.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");
}
Also used : DatabaseV4Response(com.sequenceiq.redbeams.api.endpoint.v4.database.responses.DatabaseV4Response) DatabaseConfig(com.sequenceiq.redbeams.domain.DatabaseConfig) DatabaseV4Request(com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request) Before(org.junit.Before)

Aggregations

DatabaseV4Response (com.sequenceiq.redbeams.api.endpoint.v4.database.responses.DatabaseV4Response)8 Test (org.junit.Test)5 DatabaseConfig (com.sequenceiq.redbeams.domain.DatabaseConfig)2 DatabaseV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.database.responses.DatabaseV4Response)1 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)1 DatabaseV4Request (com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1