use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class BusinessObjectDataServiceImpl method getBusinessObjectDataVersions.
@NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public BusinessObjectDataVersions getBusinessObjectDataVersions(BusinessObjectDataKey businessObjectDataKey) {
// Validate and trim the business object data key.
businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, false, false);
// Get the business object data versions based on the specified parameters.
List<BusinessObjectDataEntity> businessObjectDataEntities = businessObjectDataDao.getBusinessObjectDataEntities(businessObjectDataKey);
// Create the response.
BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions();
for (BusinessObjectDataEntity businessObjectDataEntity : businessObjectDataEntities) {
BusinessObjectDataVersion businessObjectDataVersion = new BusinessObjectDataVersion();
BusinessObjectDataKey businessObjectDataVersionKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity);
businessObjectDataVersion.setBusinessObjectDataKey(businessObjectDataVersionKey);
businessObjectDataVersion.setStatus(businessObjectDataEntity.getStatus().getCode());
businessObjectDataVersions.getBusinessObjectDataVersions().add(businessObjectDataVersion);
}
return businessObjectDataVersions;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataVersions.
@Test
public void testGetBusinessObjectDataVersions() {
// Create and persist test database entities.
createTestDatabaseEntities(SUBPARTITION_VALUES);
// Retrieve the relative business object data version by specifying values for all input parameters.
for (int businessObjectFormatVersion = INITIAL_FORMAT_VERSION; businessObjectFormatVersion < NUMBER_OF_FORMAT_VERSIONS; businessObjectFormatVersion++) {
for (int businessObjectDataVersion = INITIAL_DATA_VERSION; businessObjectDataVersion < NUMBER_OF_DATA_VERSIONS_PER_FORMAT_VERSION; businessObjectDataVersion++) {
BusinessObjectDataVersions businessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, businessObjectFormatVersion, PARTITION_VALUE, SUBPARTITION_VALUES, businessObjectDataVersion));
// Validate the returned object.
assertNotNull(businessObjectDataVersions);
assertEquals(1, businessObjectDataVersions.getBusinessObjectDataVersions().size());
businessObjectDataServiceTestHelper.validateBusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, businessObjectFormatVersion, PARTITION_VALUE, SUBPARTITION_VALUES, businessObjectDataVersion, businessObjectDataVersions.getBusinessObjectDataVersions().get(0).getBusinessObjectDataKey());
assertEquals(BDATA_STATUS, businessObjectDataVersions.getBusinessObjectDataVersions().get(0).getStatus());
}
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataAttributeTrimParameters.
@Test
public void testGetBusinessObjectDataAttributeTrimParameters() {
// Create and persist test database entities.
createTestDatabaseEntities(SUBPARTITION_VALUES);
// Retrieve the business object data versions using input parameters with leading and trailing empty spaces.
BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), INITIAL_FORMAT_VERSION, addWhitespace(PARTITION_VALUE), addWhitespace(SUBPARTITION_VALUES), INITIAL_DATA_VERSION));
// Validate the returned object.
assertNotNull(resultBusinessObjectDataVersions);
assertEquals(1, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method buildGetBusinessObjectDataVersionsResponse.
/**
* Builds a business object data get versions response.
*
* @param response the response.
* @param uri the URI of the incoming request.
*
* @throws JAXBException if a JAXB error occurred.
*/
private void buildGetBusinessObjectDataVersionsResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
Pattern pattern = Pattern.compile("/herd-app/rest/businessObjectData(/namespaces/(?<namespace>.*?))?" + "/businessObjectDefinitionNames/(?<businessObjectDefinitionName>.*?)/businessObjectFormatUsages/(?<businessObjectFormatUsage>.*?)" + "/businessObjectFormatFileTypes/(?<businessObjectFormatFileType>.*?)" + "/versions");
Matcher matcher = pattern.matcher(uri.getPath());
if (matcher.find()) {
BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions();
if (HOSTNAME_LATEST_BDATA_VERSION_EXISTS.equals(uri.getHost()) || HOSTNAME_LATEST_BDATA_VERSION_EXISTS_IN_UPLOADING_STATE.equals(uri.getHost())) {
BusinessObjectDataVersion businessObjectDataVersion = new BusinessObjectDataVersion();
businessObjectDataVersions.getBusinessObjectDataVersions().add(businessObjectDataVersion);
businessObjectDataVersion.setBusinessObjectDataKey(new BusinessObjectDataKey(getGroup(matcher, "namespace"), getGroup(matcher, "businessObjectDefinitionName"), getGroup(matcher, "businessObjectFormatUsage"), getGroup(matcher, "businessObjectFormatFileType"), 0, "2014-01-31", null, 0));
businessObjectDataVersion.setStatus(HOSTNAME_LATEST_BDATA_VERSION_EXISTS_IN_UPLOADING_STATE.equals(uri.getHost()) ? BusinessObjectDataStatusEntity.UPLOADING : BusinessObjectDataStatusEntity.VALID);
}
response.setEntity(getHttpEntity(businessObjectDataVersions));
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class BusinessObjectDataRestControllerTest method testGetBusinessObjectDataVersions.
@Test
public void testGetBusinessObjectDataVersions() {
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Create a list of business object data versions.
BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions(Arrays.asList(new BusinessObjectDataVersion()));
// Mock the external calls.
when(businessObjectDataService.getBusinessObjectDataVersions(businessObjectDataKey)).thenReturn(businessObjectDataVersions);
// Call the method under test.
BusinessObjectDataVersions result = businessObjectDataRestController.getBusinessObjectDataVersions(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_VALUE, getDelimitedFieldValues(SUBPARTITION_VALUES), FORMAT_VERSION, DATA_VERSION);
// Verify the external calls.
verify(businessObjectDataService).getBusinessObjectDataVersions(businessObjectDataKey);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(businessObjectDataVersions, result);
}
Aggregations