use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderTest method testGetDataProviderByKey.
@Test
public void testGetDataProviderByKey() {
// Create a data provider entity.
DataProviderEntity dataProviderEntity = dataProviderDaoTestHelper.createDataProviderEntity(DATA_PROVIDER_NAME);
// Retrieve the data provider entity.
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByKey(new DataProviderKey(DATA_PROVIDER_NAME)));
// Test case insensitivity of data provider key.
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByKey(new DataProviderKey(DATA_PROVIDER_NAME.toUpperCase())));
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByKey(new DataProviderKey(DATA_PROVIDER_NAME.toLowerCase())));
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderDaoImpl method getDataProviders.
@Override
public List<DataProviderKey> getDataProviders() {
// Create the criteria builder and a tuple style criteria query.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<String> criteria = builder.createQuery(String.class);
// The criteria root is the data provider.
Root<DataProviderEntity> dataProviderEntity = criteria.from(DataProviderEntity.class);
// Get the columns.
Path<String> dataProviderNameColumn = dataProviderEntity.get(DataProviderEntity_.name);
// Add the select clause.
criteria.select(dataProviderNameColumn);
// Add the order by clause.
criteria.orderBy(builder.asc(dataProviderNameColumn));
// Run the query to get a list of data provider names back.
List<String> dataProviderNames = entityManager.createQuery(criteria).getResultList();
// Populate the "keys" objects from the returned data provider names.
List<DataProviderKey> dataProviderKeys = new ArrayList<>();
for (String dataProviderName : dataProviderNames) {
dataProviderKeys.add(new DataProviderKey(dataProviderName));
}
return dataProviderKeys;
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderRestControllerTest method testDeleteDataProvider.
@Test
public void testDeleteDataProvider() throws Exception {
// Create a data provider key.
DataProviderKey dataProviderKey = new DataProviderKey(DATA_PROVIDER_NAME);
DataProvider dataProvider = new DataProvider(DATA_PROVIDER_NAME);
when(dataProviderService.deleteDataProvider(dataProviderKey)).thenReturn(dataProvider);
DataProvider deletedDataProvider = dataProviderRestController.deleteDataProvider(DATA_PROVIDER_NAME);
// Verify the external calls.
verify(dataProviderService).deleteDataProvider(dataProviderKey);
verifyNoMoreInteractions(dataProviderService);
// Validate the returned object.
assertEquals(dataProvider, deletedDataProvider);
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderServiceTest method testGetDataProviderMissingRequiredParameters.
@Test
public void testGetDataProviderMissingRequiredParameters() {
// Try to get a data provider when data provider name is not specified.
try {
dataProviderService.getDataProvider(new DataProviderKey(BLANK_TEXT));
fail("Should throw an IllegalArgumentException when data provider name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A data provider name must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderServiceTest method testDeleteDataProviderLowerCaseParameters.
@Test
public void testDeleteDataProviderLowerCaseParameters() {
// Create a data provider key.
DataProviderKey dataProviderKey = new DataProviderKey(DATA_PROVIDER_NAME);
// Create and persist a data provider entity.
dataProviderDaoTestHelper.createDataProviderEntity(DATA_PROVIDER_NAME);
// Validate that this data provider exists.
assertNotNull(dataProviderDao.getDataProviderByKey(dataProviderKey));
// Delete the data provider using lower case input parameters.
DataProvider deletedDataProvider = dataProviderService.deleteDataProvider(new DataProviderKey(DATA_PROVIDER_NAME.toLowerCase()));
// Validate the returned object.
assertEquals(new DataProvider(DATA_PROVIDER_NAME), deletedDataProvider);
// Ensure that this data provider is no longer there.
assertNull(dataProviderDao.getDataProviderByKey(dataProviderKey));
}
Aggregations