use of org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation in project herd by FINRAOS.
the class ExpectedPartitionValueServiceImpl method createExpectedPartitionValuesInformationFromEntities.
/**
* Creates the expected partition values information from the persisted entities.
*
* @param partitionKeyGroupEntity the partition key group entity
* @param expectedPartitionValueEntities the list of expected partition value entities
*
* @return the expected partition values information
*/
private ExpectedPartitionValuesInformation createExpectedPartitionValuesInformationFromEntities(PartitionKeyGroupEntity partitionKeyGroupEntity, Collection<ExpectedPartitionValueEntity> expectedPartitionValueEntities) {
// Create an expected partition values information instance.
ExpectedPartitionValuesInformation expectedPartitionValuesInformation = new ExpectedPartitionValuesInformation();
// Add the partition key group key.
PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey();
expectedPartitionValuesInformation.setPartitionKeyGroupKey(partitionKeyGroupKey);
partitionKeyGroupKey.setPartitionKeyGroupName(partitionKeyGroupEntity.getPartitionKeyGroupName());
// Add the expected partition values.
List<String> expectedPartitionValues = new ArrayList<>();
expectedPartitionValuesInformation.setExpectedPartitionValues(expectedPartitionValues);
for (ExpectedPartitionValueEntity expectedPartitionValueEntity : expectedPartitionValueEntities) {
expectedPartitionValues.add(expectedPartitionValueEntity.getPartitionValue());
}
return expectedPartitionValuesInformation;
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation in project herd by FINRAOS.
the class ExpectedPartitionValueRestControllerTest method testDeleteExpectedPartitionValues.
@Test
public void testDeleteExpectedPartitionValues() {
ExpectedPartitionValuesInformation expectedPartitionValuesInformation = new ExpectedPartitionValuesInformation(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP), expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues());
// Delete expected partition values from this partition key group.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
when(expectedPartitionValueService.deleteExpectedPartitionValues(request)).thenReturn(expectedPartitionValuesInformation);
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueRestController.deleteExpectedPartitionValues(request);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
// Verify the external calls.
verify(expectedPartitionValueService).deleteExpectedPartitionValues(request);
verifyNoMoreInteractions(expectedPartitionValueService);
// Validate the returned object.
assertEquals(expectedPartitionValuesInformation, resultPartitionValuesInformation);
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation 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.ExpectedPartitionValuesInformation 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.ExpectedPartitionValuesInformation in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesExpectedPartitionValuesNoExist.
@Test
public void testGetExpectedPartitionValuesExpectedPartitionValuesNoExist() {
// Create and persist a partition key group entity.
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Get a range of non-existing expected partition values.
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(PARTITION_VALUE, PARTITION_VALUE_2));
// Validate that returned object contains an empty list of expected partition values.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, new ArrayList<String>(), resultPartitionValuesInformation);
}
Aggregations