use of org.finra.herd.model.api.xml.BusinessObjectDataVersion 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.BusinessObjectDataVersion 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.BusinessObjectDataVersion 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