Search in sources :

Example 1 with DatabaseServerV4Request

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;
}
Also used : DatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request)

Example 2 with DatabaseServerV4Request

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());
}
Also used : DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) DatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request) Test(org.junit.Test)

Example 3 with DatabaseServerV4Request

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);
}
Also used : DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) DatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request) Test(org.junit.jupiter.api.Test)

Example 4 with DatabaseServerV4Request

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();
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) AllocateDatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request) DatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request) AllocateDatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request) DatabaseServerStatusV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerStatusV4Response) Before(org.junit.Before)

Aggregations

DatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.DatabaseServerV4Request)4 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)3 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)1 DatabaseServerStatusV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerStatusV4Response)1 DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)1 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1