use of org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesTrimParameters.
@Test
public void testCreateExpectedPartitionValuesTrimParameters() {
// Create and persist a partition key group entity.
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Add expected partition values to this partition key group with request parameters padded with whitespace characters.
ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(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.createExpectedPartitionValues(request);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValues.
@Test
public void testDeleteExpectedPartitionValues() {
// 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.
ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
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.api.xml.ExpectedPartitionValuesInformation 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.ExpectedPartitionValuesInformation in project herd by FINRAOS.
the class ExpectedPartitionValueRestControllerTest method testCreateExpectedPartitionValues.
@Test
public void testCreateExpectedPartitionValues() {
ExpectedPartitionValuesInformation expectedPartitionValuesInformation = new ExpectedPartitionValuesInformation(partitionKeyGroupServiceTestHelper.createPartitionKeyGroupKey(PARTITION_KEY_GROUP), expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues());
ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
when(expectedPartitionValueService.createExpectedPartitionValues(request)).thenReturn(expectedPartitionValuesInformation);
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueRestController.createExpectedPartitionValues(request);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
// Verify the external calls.
verify(expectedPartitionValueService).createExpectedPartitionValues(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 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);
}
Aggregations