Search in sources :

Example 31 with BusinessObjectDataAvailabilityRequest

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityStorageUnitArchived.

@Test
public void testCheckBusinessObjectDataAvailabilityStorageUnitArchived() {
    // Create VALID business object data with a "non-available" storage unit.
    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.ARCHIVED, NO_STORAGE_DIRECTORY_PATH);
    // Check the business object data availability.
    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, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS));
    // Validate the response object. Business object data should be listed as "not available" with the "ARCHIVED" 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, StorageUnitStatusEntity.ARCHIVED))), 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 32 with BusinessObjectDataAvailabilityRequest

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityFilterOnSubPartitionValues.

@Test
public void testCheckBusinessObjectDataAvailabilityFilterOnSubPartitionValues() {
    List<SchemaColumn> columns = schemaColumnDaoTestHelper.getTestSchemaColumns();
    List<SchemaColumn> partitionColumns = schemaColumnDaoTestHelper.getTestPartitionColumns();
    // Test data availability using primary partition and each of the available subpartition columns.
    for (int i = 0; i < Math.min(BusinessObjectDataEntity.MAX_SUBPARTITIONS + 1, PARTITION_COLUMNS.length); i++) {
        // Prepare test data and execute the check business object data availability request.
        businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(null, columns, partitionColumns, i + 1, SUBPARTITION_VALUES, ALLOW_DUPLICATE_BUSINESS_OBJECT_DATA);
        BusinessObjectDataAvailabilityRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
        request.getPartitionValueFilters().get(0).setPartitionKey(partitionColumns.get(i).getName());
        BusinessObjectDataAvailability resultAvailability = businessObjectDataService.checkBusinessObjectDataAvailability(request);
        // Validate the results.
        List<BusinessObjectDataStatus> expectedAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, i + 1, STORAGE_1_AVAILABLE_PARTITION_VALUES, SUBPARTITION_VALUES, DATA_VERSION, BusinessObjectDataStatusEntity.VALID, false);
        List<BusinessObjectDataStatus> expectedNotAvailableStatuses = businessObjectDataServiceTestHelper.getTestBusinessObjectDataStatuses(FORMAT_VERSION, i + 1, STORAGE_1_NOT_AVAILABLE_PARTITION_VALUES, null, DATA_VERSION, BusinessObjectDataServiceImpl.REASON_NOT_REGISTERED, false);
        businessObjectDataServiceTestHelper.validateBusinessObjectDataAvailability(request, expectedAvailableStatuses, expectedNotAvailableStatuses, resultAvailability);
    }
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus) Test(org.junit.Test)

Example 33 with BusinessObjectDataAvailabilityRequest

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

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityTwoPartitionValueRanges.

@Test
public void testCheckBusinessObjectDataAvailabilityTwoPartitionValueRanges() {
    // Prepare test data.
    businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(null);
    // Try to check business object data availability when two partition value ranges are specified.
    BusinessObjectDataAvailabilityRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    List<PartitionValueFilter> partitionValueFilters = new ArrayList<>();
    request.setPartitionValueFilters(partitionValueFilters);
    partitionValueFilters.add(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME, null, new PartitionValueRange(START_PARTITION_VALUE, END_PARTITION_VALUE), NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE));
    partitionValueFilters.add(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME, null, new PartitionValueRange(START_PARTITION_VALUE, END_PARTITION_VALUE), NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE));
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when more than one partition value range is specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("Cannot specify more than one partition value range.", e.getMessage());
    }
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) ArrayList(java.util.ArrayList) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 35 with BusinessObjectDataAvailabilityRequest

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityInvalidParameters.

@Test
public void testCheckBusinessObjectDataAvailabilityInvalidParameters() {
    BusinessObjectDataAvailabilityRequest request;
    // Prepare test data.
    businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(null);
    // Try to check business object data availability using non-existing format.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectDefinitionName("I_DO_NOT_EXIST");
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an ObjectNotFoundException when non-existing business object format is used.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(request.getNamespace(), request.getBusinessObjectDefinitionName(), request.getBusinessObjectFormatUsage(), request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion()), e.getMessage());
    }
    // Try to check business object data availability using non-existing partition key (partition column).
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.getPartitionValueFilters().get(0).setPartitionKey("I_DO_NOT_EXIST");
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when non-existing partition key is used.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("The partition key \"%s\" does not exist in first %d partition columns in the schema for business object format " + "{namespace: \"%s\", businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", businessObjectFormatFileType: \"%s\", " + "businessObjectFormatVersion: %d}.", request.getPartitionValueFilters().get(0).getPartitionKey(), BusinessObjectDataEntity.MAX_SUBPARTITIONS + 1, request.getNamespace(), request.getBusinessObjectDefinitionName(), request.getBusinessObjectFormatUsage(), request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion()), e.getMessage());
    }
    // Try to check business object data availability when both partition value filter and partition value filter list are specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setPartitionValueFilter(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME.toUpperCase(), new ArrayList<>(UNSORTED_PARTITION_VALUES), NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE));
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when both a list of partition value filters and a standalone partition value filter are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A list of partition value filters and a standalone partition value filter cannot be both specified.", e.getMessage());
    }
    // Try to check business object data availability when partition value filter has none or more than one partition value filter option specified.
    for (PartitionValueFilter partitionValueFilter : businessObjectDataServiceTestHelper.getInvalidPartitionValueFilters()) {
        request = new BusinessObjectDataAvailabilityRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(partitionValueFilter), NO_STANDALONE_PARTITION_VALUE_FILTER, DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS);
        try {
            businessObjectDataService.checkBusinessObjectDataAvailability(request);
            fail("Should throw an IllegalArgumentException when partition value filter has more than one partition value filter option.");
        } catch (IllegalArgumentException e) {
            assertEquals("Exactly one partition value filter option must be specified.", e.getMessage());
        }
    }
    // Try to check business object data availability when partition value token is specified with a partition value range.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN, END_PARTITION_VALUE);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
    }
    // Try to check business object data availability when partition value token is specified with a partition value range.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN, END_PARTITION_VALUE);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
    }
    // Try to check business object data availability when partition value token is specified with a partition value range.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(START_PARTITION_VALUE, BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
    }
    // Try to check business object data availability when partition value token is specified with a partition value range.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(END_PARTITION_VALUE, BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when partition value token is specified with a partition value range.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value token cannot be specified with a partition value range.", e.getMessage());
    }
    // Try to check business object data availability when partition value filter has start partition value which is greater than the end partition value.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(END_PARTITION_VALUE, START_PARTITION_VALUE);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when start partition value which is greater than the end partition value.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("The start partition value \"%s\" cannot be greater than the end partition value \"%s\".", END_PARTITION_VALUE, START_PARTITION_VALUE), e.getMessage());
    }
    // Try to check business object data availability when both a list of storage names and standalone storage name are specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(BLANK_TEXT);
    request.setStorageNames(STORAGE_NAMES);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when both a list of storage names and standalone storage name are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A list of storage names and a standalone storage name cannot be both specified.", e.getMessage());
    }
    // Try to check business object data availability passing a non-existing storage as a standalone storage name.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName("I_DO_NOT_EXIST");
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an ObjectNotFoundException when non-existing storage is used as a standalone storage name.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Storage with name \"%s\" doesn't exist.", request.getStorageName()), e.getMessage());
    }
    // Try to check business object data availability passing a non-existing storage in the list of storage names.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(null);
    request.setStorageNames(Arrays.asList("I_DO_NOT_EXIST"));
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an ObjectNotFoundException when non-existing storage is used in the list of storage names.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Storage with name \"%s\" doesn't exist.", request.getStorageNames().get(0)), e.getMessage());
    }
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) ArrayList(java.util.ArrayList) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Aggregations

BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)69 Test (org.junit.Test)62 BusinessObjectDataAvailability (org.finra.herd.model.api.xml.BusinessObjectDataAvailability)48 BusinessObjectDataStatus (org.finra.herd.model.api.xml.BusinessObjectDataStatus)40 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)38 ArrayList (java.util.ArrayList)27 LatestAfterPartitionValue (org.finra.herd.model.api.xml.LatestAfterPartitionValue)5 LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)5 HashMap (java.util.HashMap)4 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 BusinessObjectDataAvailabilityCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionRequest)3 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)3 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)3 BusinessObjectDataAvailabilityCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityCollectionResponse)1 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)1 BusinessObjectDataDdlCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest)1 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)1