use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithAttributeFilterValuesWithMultipleFilters.
@Test
public void testSearchBusinessObjectDataWithAttributeFilterValuesWithMultipleFilters() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2);
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_3_MIXED_CASE, ATTRIBUTE_VALUE_3);
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
key.setNamespace(NAMESPACE);
key.setBusinessObjectDefinitionName(BDEF_NAME);
List<AttributeValueFilter> attributeValueFilters = new ArrayList<>();
attributeValueFilters.add(new AttributeValueFilter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1));
attributeValueFilters.add(new AttributeValueFilter(ATTRIBUTE_NAME_2_MIXED_CASE, null));
key.setAttributeValueFilters(attributeValueFilters);
businessObjectDataSearchKeys.add(key);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
List<BusinessObjectData> resultList = result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements();
assertEquals(1, resultList.size());
for (BusinessObjectData data : resultList) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
assertEquals(2, data.getAttributes().size());
boolean foundCase1 = false, foundCase2 = false;
for (int i = 0; i < data.getAttributes().size(); i++) {
if (ATTRIBUTE_NAME_1_MIXED_CASE.equals(data.getAttributes().get(i).getName())) {
assertEquals(ATTRIBUTE_VALUE_1, data.getAttributes().get(i).getValue());
foundCase1 = true;
}
if (ATTRIBUTE_NAME_2_MIXED_CASE.equals(data.getAttributes().get(i).getName())) {
assertEquals(ATTRIBUTE_VALUE_2, data.getAttributes().get(i).getValue());
foundCase2 = true;
}
}
assertTrue(foundCase1 && foundCase2);
}
// Validate the paging information.
assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
assertEquals(Long.valueOf(1), result.getPageCount());
assertEquals(Long.valueOf(1), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(1), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectData.
@Test
public void testSearchBusinessObjectData() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
key.setNamespace(NAMESPACE);
key.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataSearchKeys.add(key);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
assertTrue(result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size() == 2);
for (BusinessObjectData data : result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements()) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
}
// Validate the paging information.
assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
assertEquals(Long.valueOf(1), result.getPageCount());
assertEquals(Long.valueOf(2), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(2), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithPageNumPageSize.
@Test
public void testSearchBusinessObjectDataWithPageNumPageSize() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
BusinessObjectDataSearchRequest request = businessObjectDataServiceTestHelper.createSimpleBusinessObjectDataSearchRequest(NAMESPACE, BDEF_NAME);
// Test getting the first page.
BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(1, 1, request);
assertEquals(1, result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size());
for (BusinessObjectData data : result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements()) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
assertEquals(FORMAT_FILE_TYPE_CODE, data.getBusinessObjectFormatFileType());
assertEquals(FORMAT_USAGE_CODE, data.getBusinessObjectFormatUsage());
}
// Validate the paging information.
assertEquals(Long.valueOf(1), result.getPageNum());
assertEquals(Long.valueOf(1), result.getPageSize());
assertEquals(Long.valueOf(2), result.getPageCount());
assertEquals(Long.valueOf(1), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(2), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
// Test getting the second page.
result = businessObjectDataService.searchBusinessObjectData(2, 1, request);
assertEquals(1, result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size());
for (BusinessObjectData data : result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements()) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
assertEquals(FORMAT_FILE_TYPE_CODE, data.getBusinessObjectFormatFileType());
assertEquals(FORMAT_USAGE_CODE_2, data.getBusinessObjectFormatUsage());
}
// Validate the paging information.
assertEquals(Long.valueOf(2), result.getPageNum());
assertEquals(Long.valueOf(1), result.getPageSize());
assertEquals(Long.valueOf(2), result.getPageCount());
assertEquals(Long.valueOf(1), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(2), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
// Test getting a larger page than there are results remaining
result = businessObjectDataService.searchBusinessObjectData(1, 3, request);
assertEquals(2, result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size());
// Validate the paging information.
assertEquals(Long.valueOf(1), result.getPageNum());
assertEquals(Long.valueOf(3), result.getPageSize());
assertEquals(Long.valueOf(1), result.getPageCount());
assertEquals(Long.valueOf(2), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(2), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
// Test getting a page that does not exist.
result = businessObjectDataService.searchBusinessObjectData(3, 1, request);
assertEquals(0, result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size());
// Validate the paging information.
assertEquals(Long.valueOf(3), result.getPageNum());
assertEquals(Long.valueOf(1), result.getPageSize());
assertEquals(Long.valueOf(2), result.getPageCount());
assertEquals(Long.valueOf(0), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(2), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataServiceDeleteBusinessObjectDataTest method testDeleteBusinessObjectDataNonS3StoragePlatform.
@Test
public void testDeleteBusinessObjectDataNonS3StoragePlatform() throws Exception {
// Create test database entities including the relative non-S3 storage entities.
createTestDatabaseEntities(STORAGE_NAME, STORAGE_PLATFORM_CODE, testS3KeyPrefix, LOCAL_FILES);
// Validate that this business object data exists.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION);
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey);
assertNotNull(businessObjectDataEntity);
// Delete the business object data with delete files flag set to true.
BusinessObjectData deletedBusinessObjectData = businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION), true);
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION, true, BDATA_STATUS, deletedBusinessObjectData);
// Ensure that this business object data is no longer there.
assertNull(businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey));
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class BusinessObjectDataServiceDeleteBusinessObjectDataTest method testDeleteBusinessObjectDataNotLatestVersion.
@Test
public void testDeleteBusinessObjectDataNotLatestVersion() {
// Create and persist a business object data which is not marked as the latest version.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, false, BDATA_STATUS);
// Validate that this business object data exists.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
assertNotNull(businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey));
// Delete the business object data.
BusinessObjectData deletedBusinessObjectData = businessObjectDataService.deleteBusinessObjectData(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), false);
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectData(businessObjectDataEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, false, BDATA_STATUS, deletedBusinessObjectData);
// Ensure that this business object data is no longer there.
assertNull(businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey));
}
Aggregations