Search in sources :

Example 31 with BusinessObjectData

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());
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) AttributeValueFilter(org.finra.herd.model.api.xml.AttributeValueFilter) BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) Test(org.junit.Test)

Example 32 with BusinessObjectData

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());
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) Test(org.junit.Test)

Example 33 with BusinessObjectData

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());
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) Test(org.junit.Test)

Example 34 with BusinessObjectData

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));
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 35 with BusinessObjectData

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));
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)150 Test (org.junit.Test)121 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)64 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)57 ArrayList (java.util.ArrayList)39 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)29 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)25 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)19 Storage (org.finra.herd.model.api.xml.Storage)19 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 Attribute (org.finra.herd.model.api.xml.Attribute)15 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)14 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)12 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)11 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)9 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)8 UploaderInputManifestDto (org.finra.herd.model.dto.UploaderInputManifestDto)8 IOException (java.io.IOException)7 BusinessObjectDataRetryStoragePolicyTransitionRequest (org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest)7 BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)7