Search in sources :

Example 1 with LatestAfterPartitionValue

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

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

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityLatestAfterPartitionValueWhenLatestDataVersionInvalid.

@Test
public void testCheckBusinessObjectDataAvailabilityLatestAfterPartitionValueWhenLatestDataVersionInvalid() {
    // Prepare test business object data, where the "latest after" partition value has no VALID business object data version and
    // the "latest after" VALID business object data partition value is eclipsed by the latest INVALID business object data version.
    storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, NO_LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, SECOND_DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.INVALID, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE_3, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.INVALID, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    // Check business object data availability using the latest after partition value filter option with the business object data version specified.
    BusinessObjectDataAvailability resultBusinessObjectDataAvailability = 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, NO_LATEST_BEFORE_PARTITION_VALUE, new LatestAfterPartitionValue(PARTITION_VALUE))), NO_STANDALONE_PARTITION_VALUE_FILTER, INITIAL_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS));
    // Validate the response object.
    assertEquals(new BusinessObjectDataAvailability(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, NO_LATEST_BEFORE_PARTITION_VALUE, new LatestAfterPartitionValue(PARTITION_VALUE))), NO_STANDALONE_PARTITION_VALUE_FILTER, INITIAL_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, Arrays.asList(new BusinessObjectDataStatus(FORMAT_VERSION, PARTITION_VALUE_3, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, BusinessObjectDataStatusEntity.INVALID)), new ArrayList<>()), resultBusinessObjectDataAvailability);
    // Check business object data availability using the latest after partition value filter option and without business object data version specified.
    resultBusinessObjectDataAvailability = 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, NO_LATEST_BEFORE_PARTITION_VALUE, new LatestAfterPartitionValue(PARTITION_VALUE))), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, NO_INCLUDE_ALL_REGISTERED_SUBPARTITIONS));
    // Validate the response object.
    assertEquals(new BusinessObjectDataAvailability(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, NO_LATEST_BEFORE_PARTITION_VALUE, new LatestAfterPartitionValue(PARTITION_VALUE))), NO_STANDALONE_PARTITION_VALUE_FILTER, NO_DATA_VERSION, NO_STORAGE_NAMES, STORAGE_NAME, Arrays.asList(new BusinessObjectDataStatus(FORMAT_VERSION, PARTITION_VALUE_2, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, BusinessObjectDataStatusEntity.VALID)), new ArrayList<>()), resultBusinessObjectDataAvailability);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) BusinessObjectDataAvailability(org.finra.herd.model.api.xml.BusinessObjectDataAvailability) ArrayList(java.util.ArrayList) BusinessObjectDataStatus(org.finra.herd.model.api.xml.BusinessObjectDataStatus) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) LatestAfterPartitionValue(org.finra.herd.model.api.xml.LatestAfterPartitionValue) Test(org.junit.Test)

Example 4 with LatestAfterPartitionValue

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

the class BusinessObjectDataServiceCheckBusinessObjectDataAvailabilityTest method testCheckBusinessObjectDataAvailabilityLatestAfterPartitionValueNoExists.

@Test
public void testCheckBusinessObjectDataAvailabilityLatestAfterPartitionValueNoExists() {
    // Create database entities required for testing.
    storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, 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, NO_LATEST_BEFORE_PARTITION_VALUE, new LatestAfterPartitionValue(PARTITION_VALUE_2))), 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 after partition value.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Failed to find partition value which is the latest after 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_2, 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) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) LatestAfterPartitionValue(org.finra.herd.model.api.xml.LatestAfterPartitionValue) Test(org.junit.Test)

Example 5 with LatestAfterPartitionValue

use of org.finra.herd.model.api.xml.LatestAfterPartitionValue 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)

Aggregations

LatestAfterPartitionValue (org.finra.herd.model.api.xml.LatestAfterPartitionValue)10 Test (org.junit.Test)9 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)8 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 LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 BusinessObjectDataDdl (org.finra.herd.model.api.xml.BusinessObjectDataDdl)2 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)1