use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderServiceImpl method createDataProvider.
@Override
public DataProvider createDataProvider(DataProviderCreateRequest request) {
// Perform the validation.
validateDataProviderCreateRequest(request);
// Get the data provider key.
DataProviderKey dataProviderKey = new DataProviderKey(request.getDataProviderName());
// Ensure a data provider with the specified data provider key doesn't already exist.
DataProviderEntity dataProviderEntity = dataProviderDao.getDataProviderByKey(dataProviderKey);
if (dataProviderEntity != null) {
throw new AlreadyExistsException(String.format("Unable to create data provider \"%s\" because it already exists.", dataProviderKey.getDataProviderName()));
}
// Create a data provider entity from the request information.
dataProviderEntity = createDataProviderEntity(request);
// Persist the new entity.
dataProviderEntity = dataProviderDao.saveAndRefresh(dataProviderEntity);
// Create and return the data provider object from the persisted entity.
return createDataProviderFromEntity(dataProviderEntity);
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderRestControllerTest method testGetDataProvider.
@Test
public void testGetDataProvider() throws Exception {
DataProvider dataProvider = new DataProvider(DATA_PROVIDER_NAME);
DataProviderKey dataProviderKey = new DataProviderKey(DATA_PROVIDER_NAME);
when(dataProviderService.getDataProvider(dataProviderKey)).thenReturn(dataProvider);
// Retrieve the data provider.
DataProvider resultDataProvider = dataProviderRestController.getDataProvider(DATA_PROVIDER_NAME);
// Verify the external calls.
verify(dataProviderService).getDataProvider(dataProviderKey);
verifyNoMoreInteractions(dataProviderService);
// Validate the returned object.
assertEquals(dataProvider, resultDataProvider);
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderRestControllerTest method testGetDataProviders.
@Test
public void testGetDataProviders() throws Exception {
DataProviderKeys dataProviderKeys = new DataProviderKeys(Arrays.asList(new DataProviderKey(DATA_PROVIDER_NAME), new DataProviderKey(DATA_PROVIDER_NAME_2)));
when(dataProviderService.getDataProviders()).thenReturn(dataProviderKeys);
// Retrieve a list of data provider keys.
DataProviderKeys resultDataProviderKeys = dataProviderRestController.getDataProviders();
// Verify the external calls.
verify(dataProviderService).getDataProviders();
verifyNoMoreInteractions(dataProviderService);
// Validate the returned object.
assertEquals(dataProviderKeys, resultDataProviderKeys);
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderServiceTest method testDeleteDataProviderNoExists.
@Test
public void testDeleteDataProviderNoExists() throws Exception {
// Try to delete a non-existing data provider.
try {
dataProviderService.deleteDataProvider(new DataProviderKey(DATA_PROVIDER_NAME));
fail("Should throw an ObjectNotFoundException when data provider doesn't exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Data provider with name \"%s\" doesn't exist.", DATA_PROVIDER_NAME), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.DataProviderKey in project herd by FINRAOS.
the class DataProviderServiceTest method testGetDataProviderLowerCaseParameters.
@Test
public void testGetDataProviderLowerCaseParameters() {
// Create and persist a data provider entity.
dataProviderDaoTestHelper.createDataProviderEntity(DATA_PROVIDER_NAME);
// Retrieve the data provider using lower case input parameters.
DataProvider resultDataProvider = dataProviderService.getDataProvider(new DataProviderKey(DATA_PROVIDER_NAME.toLowerCase()));
// Validate the returned object.
assertEquals(new DataProvider(DATA_PROVIDER_NAME), resultDataProvider);
}
Aggregations