use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesLowerCaseParameters.
@Test
public void testGetExpectedPartitionValuesLowerCaseParameters() {
// Create and persist a partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toUpperCase());
// Create and persist a single test expected partition value.
expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE.toUpperCase()));
// Get expected partition values for a range using relative input parameters in lower case.
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP.toLowerCase()), new PartitionValueRange(PARTITION_VALUE.toUpperCase(), PARTITION_VALUE.toUpperCase()));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP.toUpperCase(), Arrays.asList(PARTITION_VALUE.toUpperCase()), resultPartitionValuesInformation);
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesMissingOptionalParameters.
@Test
public void testGetExpectedPartitionValuesMissingOptionalParameters() {
// 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 the sorted list of test expected partition values.
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
int startExpectedPartitionValueIndex = 1;
int endExpectedPartitionValueIndex = testSortedExpectedPartitionValues.size() - 2;
ExpectedPartitionValuesInformation resultPartitionValuesInformation;
// Get expected partition values for a range without specifying the end expected partition value.
resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(testSortedExpectedPartitionValues.get(startExpectedPartitionValueIndex), BLANK_TEXT));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.subList(startExpectedPartitionValueIndex, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues().size()), resultPartitionValuesInformation);
// Get expected partition values for a range without specifying the start expected partition value.
resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(BLANK_TEXT, testSortedExpectedPartitionValues.get(endExpectedPartitionValueIndex)));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.subList(0, endExpectedPartitionValueIndex + 1), resultPartitionValuesInformation);
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValuesTrimParameters.
@Test
public void testDeleteExpectedPartitionValuesTrimParameters() {
// 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());
// Delete expected partition values from this partition key group with request parameters padded with whitespace characters.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(addWhitespace(PARTITION_KEY_GROUP), expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
for (int i = 0; i < request.getExpectedPartitionValues().size(); i++) {
request.getExpectedPartitionValues().set(i, addWhitespace(request.getExpectedPartitionValues().get(i)));
}
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.deleteExpectedPartitionValues(request);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
// Validate that the expected partition value entities got deleted.
assertEquals(0, partitionKeyGroupEntity.getExpectedPartitionValues().size());
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValue.
@Test
public void testGetExpectedPartitionValue() {
// 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 value for different offset values.
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
int testExpectedPartitionValueIndex = 3;
for (Integer offset : Arrays.asList(-2, 0, 2)) {
ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex)), offset);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex + offset), resultPartitionValueInformation);
}
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesTrimParameters.
@Test
public void testGetExpectedPartitionValuesTrimParameters() {
// 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 with request parameters padded with whitespace characters.
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(addWhitespace(PARTITION_KEY_GROUP)), new PartitionValueRange(addWhitespace(testSortedExpectedPartitionValues.get(0)), addWhitespace(testSortedExpectedPartitionValues.get(testSortedExpectedPartitionValues.size() - 1))));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, resultPartitionValuesInformation);
}
Aggregations