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());
}
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());
}
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");
}
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));
}
Aggregations