Search in sources :

Example 26 with BusinessObjectDataAvailability

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

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

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

the class BusinessObjectDataRestControllerTest method testCheckBusinessObjectDataAvailability.

@Test
public void testCheckBusinessObjectDataAvailability() {
    // Create a business object data availability request.
    BusinessObjectDataAvailabilityRequest businessObjectDataAvailabilityRequest = new BusinessObjectDataAvailabilityRequest();
    // Create a business object data availability response.
    BusinessObjectDataAvailability businessObjectDataAvailability = new BusinessObjectDataAvailability();
    // Mock the external calls.
    when(businessObjectDataService.checkBusinessObjectDataAvailability(businessObjectDataAvailabilityRequest)).thenReturn(businessObjectDataAvailability);
    // Call the method under test.
    BusinessObjectDataAvailability result = businessObjectDataRestController.checkBusinessObjectDataAvailability(businessObjectDataAvailabilityRequest);
    // Verify the external calls.
    verify(businessObjectDataService).checkBusinessObjectDataAvailability(businessObjectDataAvailabilityRequest);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataAvailability, result);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) Test(org.junit.Test)

Example 29 with BusinessObjectDataAvailability

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

the class BusinessObjectDataServiceTestHelper method getExpectedBusinessObjectDataAvailabilityCollectionResponse.

/**
 * Creates an expected business object data availability collection response using hard coded test values.
 *
 * @return the business object data availability collection response
 */
public BusinessObjectDataAvailabilityCollectionResponse getExpectedBusinessObjectDataAvailabilityCollectionResponse() {
    // Prepare a check availability collection response using hard coded test values.
    BusinessObjectDataAvailabilityCollectionResponse businessObjectDataAvailabilityCollectionResponse = new BusinessObjectDataAvailabilityCollectionResponse();
    // Create a list of check business object data availability responses.
    List<BusinessObjectDataAvailability> businessObjectDataAvailabilityResponses = new ArrayList<>();
    businessObjectDataAvailabilityCollectionResponse.setBusinessObjectDataAvailabilityResponses(businessObjectDataAvailabilityResponses);
    // Create a business object data availability response.
    BusinessObjectDataAvailability businessObjectDataAvailability = new BusinessObjectDataAvailability(AbstractServiceTest.NAMESPACE, AbstractServiceTest.BDEF_NAME, AbstractServiceTest.FORMAT_USAGE_CODE, AbstractServiceTest.FORMAT_FILE_TYPE_CODE, AbstractServiceTest.FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(AbstractServiceTest.PARTITION_KEY, Arrays.asList(AbstractServiceTest.PARTITION_VALUE), AbstractServiceTest.NO_PARTITION_VALUE_RANGE, AbstractServiceTest.NO_LATEST_BEFORE_PARTITION_VALUE, AbstractServiceTest.NO_LATEST_AFTER_PARTITION_VALUE)), null, AbstractServiceTest.DATA_VERSION, AbstractServiceTest.NO_STORAGE_NAMES, AbstractServiceTest.STORAGE_NAME, Arrays.asList(new BusinessObjectDataStatus(AbstractServiceTest.FORMAT_VERSION, AbstractServiceTest.PARTITION_VALUE, AbstractServiceTest.SUBPARTITION_VALUES, AbstractServiceTest.DATA_VERSION, BusinessObjectDataStatusEntity.VALID)), new ArrayList<>());
    businessObjectDataAvailabilityResponses.add(businessObjectDataAvailability);
    // Set the expected values for the flags.
    businessObjectDataAvailabilityCollectionResponse.setIsAllDataAvailable(true);
    businessObjectDataAvailabilityCollectionResponse.setIsAllDataNotAvailable(false);
    return businessObjectDataAvailabilityCollectionResponse;
}
Also used : BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) ArrayList(java.util.ArrayList) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus) BusinessObjectDataAvailabilityCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionResponse) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter)

Example 30 with BusinessObjectDataAvailability

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

the class BusinessObjectDataServiceImpl method createBusinessObjectDataAvailability.

/**
 * Creates business object data availability object instance and initialise it with the business object data availability request field values.
 *
 * @param request the business object data availability request
 *
 * @return the newly created BusinessObjectDataAvailability object instance
 */
private BusinessObjectDataAvailability createBusinessObjectDataAvailability(BusinessObjectDataAvailabilityRequest request) {
    BusinessObjectDataAvailability businessObjectDataAvailability = new BusinessObjectDataAvailability();
    businessObjectDataAvailability.setNamespace(request.getNamespace());
    businessObjectDataAvailability.setBusinessObjectDefinitionName(request.getBusinessObjectDefinitionName());
    businessObjectDataAvailability.setBusinessObjectFormatUsage(request.getBusinessObjectFormatUsage());
    businessObjectDataAvailability.setBusinessObjectFormatFileType(request.getBusinessObjectFormatFileType());
    businessObjectDataAvailability.setBusinessObjectFormatVersion(request.getBusinessObjectFormatVersion());
    businessObjectDataAvailability.setPartitionValueFilters(request.getPartitionValueFilters());
    businessObjectDataAvailability.setPartitionValueFilter(request.getPartitionValueFilter());
    businessObjectDataAvailability.setBusinessObjectDataVersion(request.getBusinessObjectDataVersion());
    businessObjectDataAvailability.setStorageNames(request.getStorageNames());
    businessObjectDataAvailability.setStorageName(request.getStorageName());
    return businessObjectDataAvailability;
}
Also used : BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability)

Aggregations

BusinessObjectDataAvailability (org.finra.herd.model.api.xml.BusinessObjectDataAvailability)51 BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)48 Test (org.junit.Test)44 BusinessObjectDataStatus (org.finra.herd.model.api.xml.BusinessObjectDataStatus)42 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)30 ArrayList (java.util.ArrayList)20 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 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)3 BusinessObjectDataAvailabilityCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionResponse)2 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)2 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)2 HashMap (java.util.HashMap)1 List (java.util.List)1 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)1 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)1 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)1 StorageEntity (org.finra.herd.model.jpa.StorageEntity)1