Search in sources :

Example 21 with BusinessObjectDataStatus

use of org.finra.herd.model.api.xml.BusinessObjectDataStatus in project herd by FINRAOS.

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityIncludeAllRegisteredSubPartitionsSecondSubPartitionDeleted.

@Test
public void testCheckBusinessObjectDataAvailabilityIncludeAllRegisteredSubPartitionsSecondSubPartitionDeleted() {
    // Create two sub-partitions one VALID and one DELETED - both with "available" storage units in a non-Glacier storage.
    storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUB_PARTITION_VALUE_1), DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUB_PARTITION_VALUE_2), DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.DELETED, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    // Check this business object data availability with "IncludeAllRegisteredSubPartitions" option enabled.
    BusinessObjectDataAvailability result = businessObjectDataService.checkBusinessObjectDataAvailability(new BusinessObjectDataAvailabilityRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(PARTITION_KEY, Arrays.asList(PARTITION_VALUE), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, INCLUDE_ALL_REGISTERED_SUBPARTITIONS));
    // Validate the response object. Only one sub-partition should be listed - the first sub-partition as VALID "available".
    assertEquals(new BusinessObjectDataAvailability(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(PARTITION_KEY, Arrays.asList(PARTITION_VALUE), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, Arrays.asList(new BusinessObjectDataStatus(FORMAT_VERSION, PARTITION_VALUE, Arrays.asList(SUB_PARTITION_VALUE_1), DATA_VERSION, BusinessObjectDataStatusEntity.VALID)), NO_NOT_AVAILABLE_STATUSES), result);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 22 with BusinessObjectDataStatus

use of org.finra.herd.model.api.xml.BusinessObjectDataStatus in project herd by FINRAOS.

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityPartitionValueRange.

@Test
public void testCheckBusinessObjectDataAvailabilityPartitionValueRange() {
    // Prepare test data.
    businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(PARTITION_KEY_GROUP);
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueProcessDatesForApril2014(PARTITION_KEY_GROUP);
    BusinessObjectDataAvailabilityRequest request;
    BusinessObjectDataAvailability resultAvailability;
    List<BusinessObjectDataStatus> expectedAvailableStatuses;
    List<BusinessObjectDataStatus> expectedNotAvailableStatuses;
    // Execute the check business object data availability request when start partition value is less than the end partition value.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(START_PARTITION_VALUE, END_PARTITION_VALUE);
    resultAvailability = businessObjectDataService.checkBusinessObjectDataAvailability(request);
    // Validate the results.
    expectedAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, PROCESS_DATE_AVAILABLE_PARTITION_VALUES, NO_SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID, false);
    expectedNotAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, PROCESS_DATE_NOT_AVAILABLE_PARTITION_VALUES, null, DATA_VERSION, BusinessObjectDataServiceImpl.REASON_NOT_REGISTERED, false);
    businessObjectDataServiceTestHelper.validateBusinessObjectDataAvailability(request, expectedAvailableStatuses, expectedNotAvailableStatuses, resultAvailability);
    // Execute the check business object data availability request when start partition value is equal to the end partition value.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(START_PARTITION_VALUE, START_PARTITION_VALUE);
    resultAvailability = businessObjectDataService.checkBusinessObjectDataAvailability(request);
    // Validate the results.
    expectedAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, Arrays.asList(START_PARTITION_VALUE), NO_SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID, false);
    expectedNotAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, null, null, DATA_VERSION, BusinessObjectDataServiceImpl.REASON_NOT_REGISTERED, false);
    businessObjectDataServiceTestHelper.validateBusinessObjectDataAvailability(request, expectedAvailableStatuses, expectedNotAvailableStatuses, resultAvailability);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus) Test(org.junit.Test)

Example 23 with BusinessObjectDataStatus

use of org.finra.herd.model.api.xml.BusinessObjectDataStatus in project herd by FINRAOS.

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityNonAvailableStorageUnitForSingleValidVersion.

@Test
public void testCheckBusinessObjectDataAvailabilityNonAvailableStorageUnitForSingleValidVersion() {
    // Create VALID business object data with an "available" storage unit.
    StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    // Check the business object data availability.
    BusinessObjectDataAvailabilityRequest request = new BusinessObjectDataAvailabilityRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(PARTITION_KEY, Arrays.asList(PARTITION_VALUE), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS);
    BusinessObjectDataAvailability result = businessObjectDataService.checkBusinessObjectDataAvailability(request);
    // Validate the response object. Business object data should be listed as "available" with the "VALID" reason.
    assertEquals(new BusinessObjectDataAvailability(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(PARTITION_KEY, Arrays.asList(PARTITION_VALUE), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, Arrays.asList(new BusinessObjectDataStatus(FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID)), NO_NOT_AVAILABLE_STATUSES), result);
    // Update the storage unit status to a non-available one.
    storageUnitEntity.setStatus(storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(STORAGE_UNIT_STATUS, DESCRIPTION, NO_STORAGE_UNIT_STATUS_AVAILABLE_FLAG_SET));
    herdDao.saveAndRefresh(storageUnitEntity);
    // Check the business object data availability.
    result = businessObjectDataService.checkBusinessObjectDataAvailability(request);
    // Validate the response object. Business object data should be listed as "not available" with the "NO_ENABLED_STORAGE_UNIT" reason.
    assertEquals(new BusinessObjectDataAvailability(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(PARTITION_KEY, Arrays.asList(PARTITION_VALUE), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, NO_AVAILABLE_STATUSES, Arrays.asList(new BusinessObjectDataStatus(FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_UNIT_STATUS))), result);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 24 with BusinessObjectDataStatus

use of org.finra.herd.model.api.xml.BusinessObjectDataStatus in project herd by FINRAOS.

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityPartitionValueListStandalonePartitionValueFilter.

@Test
public void testCheckBusinessObjectDataAvailabilityPartitionValueListStandalonePartitionValueFilter() {
    // Prepare test data and execute the check business object data availability request with a standalone partition value filter.
    businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(null);
    BusinessObjectDataAvailabilityRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setPartitionValueFilter(request.getPartitionValueFilters().get(0));
    request.setPartitionValueFilters(null);
    BusinessObjectDataAvailability resultAvailability = businessObjectDataService.checkBusinessObjectDataAvailability(request);
    // Validate the results.
    List<BusinessObjectDataStatus> expectedAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, STORAGE_1_AVAILABLE_PARTITION_VALUES, NO_SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID, false);
    List<BusinessObjectDataStatus> expectedNotAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, STORAGE_1_NOT_AVAILABLE_PARTITION_VALUES, null, DATA_VERSION, BusinessObjectDataServiceImpl.REASON_NOT_REGISTERED, true);
    businessObjectDataServiceTestHelper.validateBusinessObjectDataAvailability(request, expectedAvailableStatuses, expectedNotAvailableStatuses, resultAvailability);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus) Test(org.junit.Test)

Example 25 with BusinessObjectDataStatus

use of org.finra.herd.model.api.xml.BusinessObjectDataStatus in project herd by FINRAOS.

the class BusinessObjectDataServiceTestHelper method getTestBusinessObjectDataStatuses.

/**
 * Creates and returns a list of business object data status elements initialised per provided parameters.
 *
 * @param businessObjectFormatVersion the business object format version
 * @param partitionColumnPosition the position of the partition column (one-based numbering)
 * @param partitionValues the list of partition values
 * @param subPartitionValues the list of subpartition values
 * @param businessObjectDataVersion the business object data version
 * @param reason the reason for the not available business object data
 * @param useSinglePartitionValue specifies if not available statuses should be generated using single partition value logic
 *
 * @return the newly created list of business object data status elements
 */
public List<BusinessObjectDataStatus> getTestBusinessObjectDataStatuses(Integer businessObjectFormatVersion, int partitionColumnPosition, List<String> partitionValues, List<String> subPartitionValues, Integer businessObjectDataVersion, String reason, boolean useSinglePartitionValue) {
    List<BusinessObjectDataStatus> businessObjectDataStatuses = new ArrayList<>();
    if (partitionValues != null) {
        for (String partitionValue : partitionValues) {
            BusinessObjectDataStatus businessObjectDataStatus = new BusinessObjectDataStatus();
            businessObjectDataStatuses.add(businessObjectDataStatus);
            businessObjectDataStatus.setBusinessObjectFormatVersion(businessObjectFormatVersion);
            businessObjectDataStatus.setBusinessObjectDataVersion(businessObjectDataVersion);
            businessObjectDataStatus.setReason(reason);
            if (BusinessObjectDataServiceImpl.REASON_NOT_REGISTERED.equals(reason)) {
                // We are generating business object data status for a not registered business object data.
                if (partitionColumnPosition == BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION) {
                    // This is a not-available not-registered business object data searched on a primary partition.
                    businessObjectDataStatus.setPartitionValue(partitionValue);
                    businessObjectDataStatus.setSubPartitionValues(useSinglePartitionValue ? null : Arrays.asList("", "", "", ""));
                } else {
                    // This is a not-available not-registered business object data searched on a sub-partition value.
                    if (useSinglePartitionValue) {
                        businessObjectDataStatus.setPartitionValue(partitionValue);
                    } else {
                        businessObjectDataStatus.setPartitionValue("");
                        businessObjectDataStatus.setSubPartitionValues(Arrays.asList("", "", "", ""));
                        businessObjectDataStatus.getSubPartitionValues().set(partitionColumnPosition - 2, partitionValue);
                    }
                }
            } else if (partitionColumnPosition == BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION) {
                // This is a found business object data selected on primary partition value.
                businessObjectDataStatus.setPartitionValue(partitionValue);
                businessObjectDataStatus.setSubPartitionValues(subPartitionValues);
            } else {
                // This is a found business object data selected on a subpartition column.
                businessObjectDataStatus.setPartitionValue(AbstractServiceTest.PARTITION_VALUE);
                List<String> testSubPartitionValues = new ArrayList<>(subPartitionValues);
                // Please note that the value of the second partition column is located at index 0.
                testSubPartitionValues.set(partitionColumnPosition - 2, partitionValue);
                businessObjectDataStatus.setSubPartitionValues(testSubPartitionValues);
            }
        }
    }
    return businessObjectDataStatuses;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus)

Aggregations

BusinessObjectDataStatus (org.finra.herd.model.api.xml.BusinessObjectDataStatus)46 BusinessObjectDataAvailability (org.finra.herd.model.api.xml.BusinessObjectDataAvailability)42 BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)40 Test (org.junit.Test)39 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)27 ArrayList (java.util.ArrayList)18 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 LatestAfterPartitionValue (org.finra.herd.model.api.xml.LatestAfterPartitionValue)3 LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)3 List (java.util.List)2 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)2 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)2 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)2 HashMap (java.util.HashMap)1 BusinessObjectDataAvailabilityCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionResponse)1 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)1 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)1