use of org.finra.herd.model.api.xml.PartitionKeyGroupKey in project herd by FINRAOS.
the class ExpectedPartitionValueRestControllerTest method testGetExpectedPartitionValues.
@Test
public void testGetExpectedPartitionValues() {
PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey();
partitionKeyGroupKey.setPartitionKeyGroupName(PARTITION_KEY_GROUP);
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
int startExpectedPartitionValueIndex = 1;
int endExpectedPartitionValueIndex = testSortedExpectedPartitionValues.size() - 2;
PartitionValueRange partitionValueRange = new PartitionValueRange();
partitionValueRange.setStartPartitionValue(testSortedExpectedPartitionValues.get(startExpectedPartitionValueIndex));
partitionValueRange.setEndPartitionValue(testSortedExpectedPartitionValues.get(endExpectedPartitionValueIndex));
ExpectedPartitionValuesInformation expectedPartitionValuesInformation = new ExpectedPartitionValuesInformation(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP), expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues().subList(startExpectedPartitionValueIndex, endExpectedPartitionValueIndex));
when(expectedPartitionValueService.getExpectedPartitionValues(partitionKeyGroupKey, partitionValueRange)).thenReturn(expectedPartitionValuesInformation);
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueRestController.getExpectedPartitionValues(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(startExpectedPartitionValueIndex), testSortedExpectedPartitionValues.get(endExpectedPartitionValueIndex));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.subList(startExpectedPartitionValueIndex, endExpectedPartitionValueIndex), resultPartitionValuesInformation);
// Verify the external calls.
verify(expectedPartitionValueService).getExpectedPartitionValues(partitionKeyGroupKey, partitionValueRange);
verifyNoMoreInteractions(expectedPartitionValueService);
// Validate the returned object.
assertEquals(expectedPartitionValuesInformation, resultPartitionValuesInformation);
}
use of org.finra.herd.model.api.xml.PartitionKeyGroupKey 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.api.xml.PartitionKeyGroupKey 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.api.xml.PartitionKeyGroupKey in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesPartitionKeyGroupNoExists.
@Test
public void testGetExpectedPartitionValuesPartitionKeyGroupNoExists() {
// Try to perform a get expected partition values using a non-existing partition key group name.
String partitionKeyGroupName = "I_DO_NOT_EXIST";
try {
expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(partitionKeyGroupName), new PartitionValueRange(PARTITION_VALUE, PARTITION_VALUE));
fail("Should throw an IllegalArgumentException when partition key group does not exist.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Partition key group \"%s\" doesn't exist.", partitionKeyGroupName), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.PartitionKeyGroupKey in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesMissingRequiredParameters.
@Test
public void testGetExpectedPartitionValuesMissingRequiredParameters() {
// Try to perform a get expected partition values without specifying partition key group name.
try {
expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(BLANK_TEXT), new PartitionValueRange(PARTITION_VALUE, PARTITION_VALUE));
fail("Should throw an IllegalArgumentException when partition key group is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A partition key group name must be specified.", e.getMessage());
}
// Try to perform a get expected partition values without specifying neither start or end expected partition values for the range.
try {
expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(BLANK_TEXT, BLANK_TEXT));
fail("Should throw an IllegalArgumentException when both start and end expected partition values are not specified.");
} catch (IllegalArgumentException e) {
assertEquals("At least one start or end expected partition value must be specified.", e.getMessage());
}
}
Aggregations