Search in sources :

Example 1 with DatabaseV4Request

use of com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request in project cloudbreak by hortonworks.

the class DatabaseV4RequestToDatabaseConfigConverterTest method testConvert.

@Test
public void testConvert() {
    DatabaseV4Request request = new DatabaseV4Request();
    request.setType(TYPE);
    request.setName(NAME);
    request.setEnvironmentCrn(ENVIRONMENT_CRN);
    request.setDescription(DESCRIPTION);
    request.setConnectionURL(CONNECTION_URL);
    request.setConnectionPassword(CONNECTION_PASSWORD);
    request.setConnectionUserName(CONNECTION_USERNAME);
    request.setConnectionDriver(CONNECTION_DRIVER);
    when(databaseVendorUtil.getVendorByJdbcUrl(CONNECTION_URL)).thenReturn(Optional.of(DatabaseVendor.POSTGRES));
    DatabaseConfig databaseConfig = underTest.convert(request);
    assertEquals(NAME, databaseConfig.getName());
    assertEquals(TYPE, databaseConfig.getType());
    assertEquals(ENVIRONMENT_CRN, databaseConfig.getEnvironmentId());
    assertEquals(DESCRIPTION, databaseConfig.getDescription());
    assertEquals(CONNECTION_URL, databaseConfig.getConnectionURL());
    assertEquals(CONNECTION_PASSWORD, databaseConfig.getConnectionPassword().getRaw());
    assertEquals(CONNECTION_USERNAME, databaseConfig.getConnectionUserName().getRaw());
    assertEquals(CONNECTION_DRIVER, databaseConfig.getConnectionDriver());
    assertEquals(DatabaseVendor.POSTGRES, databaseConfig.getDatabaseVendor());
    assertEquals(ResourceStatus.USER_MANAGED, databaseConfig.getStatus());
    verify(databaseVendorUtil).getVendorByJdbcUrl(CONNECTION_URL);
    verify(missingResourceNameGenerator, never()).generateName(any());
}
Also used : DatabaseV4Request(com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request) DatabaseConfig(com.sequenceiq.redbeams.domain.DatabaseConfig) Test(org.junit.Test)

Example 2 with DatabaseV4Request

use of com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request in project cloudbreak by hortonworks.

the class DatabaseTestV4RequestTest method testGettersAndSetters.

@Test
public void testGettersAndSetters() {
    DatabaseV4Identifiers identifiers = new DatabaseV4Identifiers();
    request.setExistingDatabase(identifiers);
    assertEquals(identifiers, request.getExistingDatabase());
    DatabaseV4Request serverRequest = new DatabaseV4Request();
    serverRequest.setName("mydb1");
    request.setDatabase(serverRequest);
    assertEquals("mydb1", request.getDatabase().getName());
}
Also used : DatabaseV4Identifiers(com.sequenceiq.redbeams.api.endpoint.v4.database.base.DatabaseV4Identifiers) Test(org.junit.Test)

Example 3 with DatabaseV4Request

use of com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request 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)

Example 4 with DatabaseV4Request

use of com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request in project cloudbreak by hortonworks.

the class DatabaseVendorAndServiceValidatorTest method testIsValid.

@Test
public void testIsValid() {
    DatabaseV4Request request = new DatabaseV4Request();
    request.setType(serviceName);
    request.setConnectionURL(new DatabaseCommon().getJdbcConnectionUrl(databaseVendor.jdbcUrlDriverId(), "mydb.example.com", 1234, Optional.of(serviceName)));
    assertEquals(expectedResult, underTest.isValid(request, context));
    int expectedTimes = expectedResult ? 0 : 1;
    verify(context, times(expectedTimes)).buildConstraintViolationWithTemplate(any(String.class));
}
Also used : DatabaseCommon(com.sequenceiq.cloudbreak.common.database.DatabaseCommon) DatabaseV4Request(com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request) Test(org.junit.Test)

Aggregations

DatabaseV4Request (com.sequenceiq.redbeams.api.endpoint.v4.database.request.DatabaseV4Request)3 Test (org.junit.Test)3 DatabaseConfig (com.sequenceiq.redbeams.domain.DatabaseConfig)2 DatabaseCommon (com.sequenceiq.cloudbreak.common.database.DatabaseCommon)1 DatabaseV4Identifiers (com.sequenceiq.redbeams.api.endpoint.v4.database.base.DatabaseV4Identifiers)1 DatabaseV4Response (com.sequenceiq.redbeams.api.endpoint.v4.database.responses.DatabaseV4Response)1 Before (org.junit.Before)1