Search in sources :

Example 1 with LatestBeforePartitionValue

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

the class BusinessObjectDataHelper method validatePartitionValueFilters.

/**
 * Validates a list of partition value filters or a standalone partition filter. This method makes sure that a partition value filter contains exactly one
 * partition value range or a non-empty partition value list. This method also makes sure that there is no more than one partition value range specified
 * across all partition value filters.
 *
 * @param partitionValueFilters the list of partition value filters to validate
 * @param standalonePartitionValueFilter the standalone partition value filter to validate
 * @param allowPartitionValueTokens specifies whether the partition value filter is allowed to contain partition value tokens
 */
public void validatePartitionValueFilters(List<PartitionValueFilter> partitionValueFilters, PartitionValueFilter standalonePartitionValueFilter, boolean allowPartitionValueTokens) {
    // Make sure that request does not contain both a list of partition value filters and a standalone partition value filter.
    Assert.isTrue(partitionValueFilters == null || standalonePartitionValueFilter == null, "A list of partition value filters and a standalone partition value filter cannot be both specified.");
    List<PartitionValueFilter> partitionValueFiltersToValidate = new ArrayList<>();
    if (partitionValueFilters != null) {
        partitionValueFiltersToValidate.addAll(partitionValueFilters);
    }
    if (standalonePartitionValueFilter != null) {
        partitionValueFiltersToValidate.add(standalonePartitionValueFilter);
    }
    // Make sure that at least one partition value filter is specified.
    Assert.notEmpty(partitionValueFiltersToValidate, "At least one partition value filter must be specified.");
    // Validate and trim partition value filters.
    int partitionValueRangesCount = 0;
    for (PartitionValueFilter partitionValueFilter : partitionValueFiltersToValidate) {
        // Partition key is required when request contains a partition value filter list.
        if (partitionValueFilters != null) {
            Assert.hasText(partitionValueFilter.getPartitionKey(), "A partition key must be specified.");
        }
        // Trim partition key value.
        if (StringUtils.isNotBlank(partitionValueFilter.getPartitionKey())) {
            partitionValueFilter.setPartitionKey(partitionValueFilter.getPartitionKey().trim());
        }
        PartitionValueRange partitionValueRange = partitionValueFilter.getPartitionValueRange();
        List<String> partitionValues = partitionValueFilter.getPartitionValues();
        LatestBeforePartitionValue latestBeforePartitionValue = partitionValueFilter.getLatestBeforePartitionValue();
        LatestAfterPartitionValue latestAfterPartitionValue = partitionValueFilter.getLatestAfterPartitionValue();
        // Validate that we have exactly one partition filter option specified.
        List<Boolean> partitionFilterOptions = Arrays.asList(partitionValueRange != null, partitionValues != null, latestBeforePartitionValue != null, latestAfterPartitionValue != null);
        Assert.isTrue(Collections.frequency(partitionFilterOptions, Boolean.TRUE) == 1, "Exactly one partition value filter option must be specified.");
        if (partitionValueRange != null) {
            // A "partition value range" filter option is specified.
            // Only one partition value range is allowed across all partition value filters.
            partitionValueRangesCount++;
            Assert.isTrue(partitionValueRangesCount < 2, "Cannot specify more than one partition value range.");
            // Validate start partition value for the partition value range.
            Assert.hasText(partitionValueRange.getStartPartitionValue(), "A start partition value for the partition value range must be specified.");
            partitionValueRange.setStartPartitionValue(partitionValueRange.getStartPartitionValue().trim());
            // Validate end partition value for the partition value range.
            Assert.hasText(partitionValueRange.getEndPartitionValue(), "An end partition value for the partition value range must be specified.");
            partitionValueRange.setEndPartitionValue(partitionValueRange.getEndPartitionValue().trim());
            // Validate that partition value tokens are not specified as start and end partition values.
            // This check is required, regardless if partition value tokens are allowed or not.
            Assert.isTrue(!partitionValueRange.getStartPartitionValue().equals(BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN) && !partitionValueRange.getStartPartitionValue().equals(BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN) && !partitionValueRange.getEndPartitionValue().equals(BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN) && !partitionValueRange.getEndPartitionValue().equals(BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN), "A partition value token cannot be specified with a partition value range.");
            // Using string compare, validate that start partition value is less than or equal to end partition value.
            Assert.isTrue(partitionValueRange.getStartPartitionValue().compareTo(partitionValueRange.getEndPartitionValue()) <= 0, String.format("The start partition value \"%s\" cannot be greater than the end partition value \"%s\".", partitionValueRange.getStartPartitionValue(), partitionValueRange.getEndPartitionValue()));
        } else if (partitionValues != null) {
            // A "partition value list" filter option is specified.
            // Validate that the list contains at least one partition value.
            Assert.isTrue(!partitionValues.isEmpty(), "At least one partition value must be specified.");
            for (int i = 0; i < partitionValues.size(); i++) {
                String partitionValue = partitionValues.get(i);
                Assert.hasText(partitionValue, "A partition value must be specified.");
                partitionValue = partitionValue.trim();
                // When partition value tokens are not allowed, validate that they are not specified as one of partition values.
                if (!allowPartitionValueTokens) {
                    Assert.isTrue(!partitionValue.equals(BusinessObjectDataService.MAX_PARTITION_VALUE_TOKEN) && !partitionValue.equals(BusinessObjectDataService.MIN_PARTITION_VALUE_TOKEN), "A partition value token cannot be specified as one of partition values.");
                }
                partitionValues.set(i, partitionValue);
            }
        } else if (latestBeforePartitionValue != null) {
            // A "latest before partition value" filter option is specified.
            Assert.hasText(latestBeforePartitionValue.getPartitionValue(), "A partition value must be specified.");
            latestBeforePartitionValue.setPartitionValue(latestBeforePartitionValue.getPartitionValue().trim());
        } else {
            // A "latest after partition value" filter option is specified.
            Assert.hasText(latestAfterPartitionValue.getPartitionValue(), "A partition value must be specified.");
            latestAfterPartitionValue.setPartitionValue(latestAfterPartitionValue.getPartitionValue().trim());
        }
    }
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) LatestBeforePartitionValue(org.finra.herd.model.api.xml.LatestBeforePartitionValue) ArrayList(java.util.ArrayList) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) LatestAfterPartitionValue(org.finra.herd.model.api.xml.LatestAfterPartitionValue)

Example 2 with LatestBeforePartitionValue

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityMissingRequiredParameters.

@Test
public void testCheckBusinessObjectDataAvailabilityMissingRequiredParameters() {
    BusinessObjectDataAvailabilityRequest request;
    // Try to check business object data availability when business object definition name parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectDefinitionName(BLANK_TEXT);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when business object definition name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to check business object data availability when business object format usage parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectFormatUsage(BLANK_TEXT);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when business object format usage parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to check business object data availability when business object format file type parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectFormatFileType(BLANK_TEXT);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when business object format file type parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to check business object data availability when partition key is not specified in one of the partition value filters.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.getPartitionValueFilters().get(0).setPartitionKey(BLANK_TEXT);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when partition key is not specified in one of the partition value filters.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition key must be specified.", e.getMessage());
    }
    // Try to check business object data availability when start partition value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(BLANK_TEXT, END_PARTITION_VALUE);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when start partition values is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A start partition value for the partition value range must be specified.", e.getMessage());
    }
    // Try to check business object data availability when end partition value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(START_PARTITION_VALUE, BLANK_TEXT);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when end partition values is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An end partition value for the partition value range must be specified.", e.getMessage());
    }
    // Try to check business object data availability when partition value list has no partition values specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(new ArrayList<>());
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when partition value list has no partition values specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least one partition value must be specified.", e.getMessage());
    }
    // Try to check business object data availability when one of the partition values in the partition value list is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.getPartitionValueFilters().get(0).getPartitionValues().add(BLANK_TEXT);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when one of the partition values in the partition value list is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value must be specified.", e.getMessage());
    }
    // Try to check business object data availability when the latest before partition value filter option has no partition value specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(NO_PARTITION_VALUES);
    for (String partitionValue : Arrays.asList(null, BLANK_TEXT)) {
        request.getPartitionValueFilters().get(0).setLatestBeforePartitionValue(new LatestBeforePartitionValue(partitionValue));
        try {
            businessObjectDataService.checkBusinessObjectDataAvailability(request);
            fail("Should throw an IllegalArgumentException when the latest before partition value filter option has no partition value specified.");
        } catch (IllegalArgumentException e) {
            assertEquals("A partition value must be specified.", e.getMessage());
        }
    }
    // Try to check business object data availability when the latest after partition value filter option has no partition value specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(NO_PARTITION_VALUES);
    for (String partitionValue : Arrays.asList(null, BLANK_TEXT)) {
        request.getPartitionValueFilters().get(0).setLatestAfterPartitionValue(new LatestAfterPartitionValue(partitionValue));
        try {
            businessObjectDataService.checkBusinessObjectDataAvailability(request);
            fail("Should throw an IllegalArgumentException when the latest after partition value filter option has no partition value specified.");
        } catch (IllegalArgumentException e) {
            assertEquals("A partition value must be specified.", e.getMessage());
        }
    }
    // Try to check business object data availability when standalone storage name parameter value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(BLANK_TEXT);
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when standalone storage name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage name must be specified.", e.getMessage());
    }
    // Try to check business object data availability when standalone storage name parameter value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(null);
    request.setStorageNames(Arrays.asList(BLANK_TEXT));
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(request);
        fail("Should throw an IllegalArgumentException when storage name parameter in the list of storage names is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage name must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) LatestBeforePartitionValue(org.finra.herd.model.api.xml.LatestBeforePartitionValue) ArrayList(java.util.ArrayList) LatestAfterPartitionValue(org.finra.herd.model.api.xml.LatestAfterPartitionValue) Test(org.junit.Test)

Example 3 with LatestBeforePartitionValue

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityLatestBeforePartitionValueNoExists.

@Test
public void testCheckBusinessObjectDataAvailabilityLatestBeforePartitionValueNoExists() {
    // Create database entities required for testing.
    storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, DATA_VERSION, true, BusinessObjectDataStatusEntity.VALID, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    // Try to check an availability using a latest before partition value filter option when the latest partition value does not exist.
    try {
        businessObjectDataService.checkBusinessObjectDataAvailability(new BusinessObjectDataAvailabilityRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(PARTITION_KEY, NO_PARTITION_VALUES, NO_PARTITION_VALUE_RANGE, new LatestBeforePartitionValue(PARTITION_VALUE), NO_LATEST_AFTER_PARTITION_VALUE)), null, DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS));
        fail("Suppose to throw an ObjectNotFoundException when failed to find the latest before partition value.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Failed to find partition value which is the latest before partition value = \"%s\" " + "for partition key = \"%s\" due to no available business object data " + "in \"%s\" storage that satisfies the search criteria. Business object data {namespace: \"%s\", " + "businessObjectDefinitionName: \"%s\", businessObjectFormatUsage: \"%s\", businessObjectFormatFileType: \"%s\", " + "businessObjectFormatVersion: %d, businessObjectDataVersion: %d}", PARTITION_VALUE, PARTITION_KEY, STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, DATA_VERSION), e.getMessage());
    }
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) LatestBeforePartitionValue(org.finra.herd.model.api.xml.LatestBeforePartitionValue) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 4 with LatestBeforePartitionValue

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

the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlMissingRequiredParameters.

@Test
public void testGenerateBusinessObjectDataDdlMissingRequiredParameters() {
    BusinessObjectDataDdlRequest request;
    // Try to retrieve business object data ddl when business object definition name parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectDefinitionName(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when business object definition name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when business object format usage parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectFormatUsage(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when business object format usage parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when business object format file type parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectFormatFileType(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when business object format file type parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when partition key is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.getPartitionValueFilters().get(0).setPartitionKey(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when partition key is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition key must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when start partition value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(BLANK_TEXT, END_PARTITION_VALUE);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when start partition values is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A start partition value for the partition value range must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when end partition value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(START_PARTITION_VALUE, BLANK_TEXT, null);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when end partition values is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An end partition value for the partition value range must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when partition value list has no partition values specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(new ArrayList<>());
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when partition value list has no partition values specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least one partition value must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when one of the partition values in the partition value list is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.getPartitionValueFilters().get(0).getPartitionValues().add(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when one of the partition values in the partition value list is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when the latest before partition value filter option has no partition value specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(NO_PARTITION_VALUES);
    for (String partitionValue : Arrays.asList(null, BLANK_TEXT)) {
        request.getPartitionValueFilters().get(0).setLatestBeforePartitionValue(new LatestBeforePartitionValue(partitionValue));
        try {
            businessObjectDataService.generateBusinessObjectDataDdl(request);
            fail("Should throw an IllegalArgumentException when the latest before partition value filter option has no partition value specified.");
        } catch (IllegalArgumentException e) {
            assertEquals("A partition value must be specified.", e.getMessage());
        }
    }
    // Try to retrieve business object data ddl when the latest after partition value filter option has no partition value specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(NO_PARTITION_VALUES);
    for (String partitionValue : Arrays.asList(null, BLANK_TEXT)) {
        request.getPartitionValueFilters().get(0).setLatestAfterPartitionValue(new LatestAfterPartitionValue(partitionValue));
        try {
            businessObjectDataService.generateBusinessObjectDataDdl(request);
            fail("Should throw an IllegalArgumentException when the latest after partition value filter option has no partition value specified.");
        } catch (IllegalArgumentException e) {
            assertEquals("A partition value must be specified.", e.getMessage());
        }
    }
    // Try to retrieve business object data ddl when standalone storage name parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when standalone storage name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage name must be specified.", e.getMessage());
    }
    // Try to check business object data availability when standalone storage name parameter value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(null);
    request.setStorageNames(Arrays.asList(BLANK_TEXT));
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when storage name parameter in the list of storage names is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage name must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when output format parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setOutputFormat(null);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when output format parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An output format must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when table name parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setTableName(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when table name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A table name must be specified.", e.getMessage());
    }
}
Also used : LatestBeforePartitionValue(org.finra.herd.model.api.xml.LatestBeforePartitionValue) BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) ArrayList(java.util.ArrayList) LatestAfterPartitionValue(org.finra.herd.model.api.xml.LatestAfterPartitionValue) Test(org.junit.Test)

Example 5 with LatestBeforePartitionValue

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

the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlLatestBeforePartitionValueNoStorage.

@Test
public void testGenerateBusinessObjectDataDdlLatestBeforePartitionValueNoStorage() {
    // Prepare database entities required for testing.
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting(PARTITION_VALUE);
    // Check an availability using a latest before partition value filter option and without specifying any storage.
    for (String upperBoundPartitionValue : Arrays.asList(PARTITION_VALUE, PARTITION_VALUE_2)) {
        BusinessObjectDataDdl resultBusinessObjectDataDdl = businessObjectDataService.generateBusinessObjectDataDdl(new BusinessObjectDataDdlRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME, NO_PARTITION_VALUES, NO_PARTITION_VALUE_RANGE, new LatestBeforePartitionValue(upperBoundPartitionValue), NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, DATA_VERSION, NO_STORAGE_NAMES, NO_STORAGE_NAME, BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL, TABLE_NAME, NO_CUSTOM_DDL_NAME, INCLUDE_DROP_TABLE_STATEMENT, INCLUDE_IF_NOT_EXISTS_OPTION, INCLUDE_DROP_PARTITIONS, NO_ALLOW_MISSING_DATA, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS, NO_SUPPRESS_SCAN_FOR_UNREGISTERED_SUBPARTITIONS));
        // Validate the response object.
        assertEquals(new BusinessObjectDataDdl(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(FIRST_PARTITION_COLUMN_NAME, NO_PARTITION_VALUES, NO_PARTITION_VALUE_RANGE, new LatestBeforePartitionValue(upperBoundPartitionValue), NO_LATEST_AFTER_PARTITION_VALUE)), NO_STANDALONE_PARTITION_VALUE_FILTER, DATA_VERSION, NO_STORAGE_NAMES, NO_STORAGE_NAME, BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL, TABLE_NAME, NO_CUSTOM_DDL_NAME, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataDdl(PARTITION_VALUE)), resultBusinessObjectDataDdl);
    }
}
Also used : LatestBeforePartitionValue(org.finra.herd.model.api.xml.LatestBeforePartitionValue) BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Aggregations

LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)11 Test (org.junit.Test)10 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)9 ArrayList (java.util.ArrayList)6 BusinessObjectDataAvailabilityRequest (org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest)5 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)4 BusinessObjectDataAvailability (org.finra.herd.model.api.xml.BusinessObjectDataAvailability)3 BusinessObjectDataStatus (org.finra.herd.model.api.xml.BusinessObjectDataStatus)3 LatestAfterPartitionValue (org.finra.herd.model.api.xml.LatestAfterPartitionValue)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 BusinessObjectDataDdl (org.finra.herd.model.api.xml.BusinessObjectDataDdl)2 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)1 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)1 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1