use of org.finra.herd.model.api.xml.PartitionValueRange 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());
}
}
use of org.finra.herd.model.api.xml.PartitionValueRange in project herd by FINRAOS.
the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlTwoPartitionValueRanges.
@Test
public void testGenerateBusinessObjectDataDdlTwoPartitionValueRanges() {
// Prepare test data.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting();
// Try to retrieve business object data ddl when two partition value ranges are specified.
BusinessObjectDataDdlRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES, CUSTOM_DDL_NAME);
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.generateBusinessObjectDataDdl(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());
}
}
use of org.finra.herd.model.api.xml.PartitionValueRange in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValues.
@Test
public void testGetExpectedPartitionValues() {
// Create and persist a partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Create and persist a list of test expected partition values.
expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
// Get expected partition values for a range.
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
int startExpectedPartitionValueIndex = 1;
int endExpectedPartitionValueIndex = testSortedExpectedPartitionValues.size() - 2;
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(testSortedExpectedPartitionValues.get(startExpectedPartitionValueIndex), testSortedExpectedPartitionValues.get(endExpectedPartitionValueIndex)));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.subList(startExpectedPartitionValueIndex, endExpectedPartitionValueIndex + 1), resultPartitionValuesInformation);
}
use of org.finra.herd.model.api.xml.PartitionValueRange in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesUpperCaseParameters.
@Test
public void testGetExpectedPartitionValuesUpperCaseParameters() {
// Create and persist a partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toLowerCase());
// Create and persist a single test expected partition value.
expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE.toLowerCase()));
// Get expected partition values for a range using relative input parameters in upper case.
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toUpperCase()), new PartitionValueRange(PARTITION_VALUE.toLowerCase(), PARTITION_VALUE.toLowerCase()));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP.toLowerCase(), Arrays.asList(PARTITION_VALUE.toLowerCase()), resultPartitionValuesInformation);
}
use of org.finra.herd.model.api.xml.PartitionValueRange in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesInvalidParameters.
@Test
public void testGetExpectedPartitionValuesInvalidParameters() {
// Try to perform a get expected partition values with the start expected partition value being greater than the end expected partition value.
try {
expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(PARTITION_VALUE_2, PARTITION_VALUE));
fail("Should throw an IllegalArgumentException when the start expected partition value being greater than the end expected partition value.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("The start expected partition value \"%s\" cannot be greater than the end expected partition value \"%s\".", PARTITION_VALUE_2, PARTITION_VALUE), e.getMessage());
}
}
Aggregations