use of org.finra.herd.model.api.xml.ExpectedPartitionValueInformation in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValueMissingOptionalParameters.
@Test
public void testGetExpectedPartitionValueMissingOptionalParameters() {
// 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 without specifying the offset.
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
int testExpectedPartitionValueIndex = 3;
ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex)), null);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex), resultPartitionValueInformation);
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValueInformation in project herd by FINRAOS.
the class ExpectedPartitionValueRestControllerTest method testGetExpectedPartitionValue.
@Test
public void testGetExpectedPartitionValue() {
int offset = 1;
String partitionOffset = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues().get(offset);
ExpectedPartitionValueKey expectedPartitionValueKey = new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, partitionOffset);
ExpectedPartitionValueInformation expectedPartitionValuesInformation = new ExpectedPartitionValueInformation(expectedPartitionValueKey);
when(expectedPartitionValueService.getExpectedPartitionValue(expectedPartitionValueKey, offset)).thenReturn(expectedPartitionValuesInformation);
ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueRestController.getExpectedPartitionValue(PARTITION_KEY_GROUP, partitionOffset, offset);
// Verify the external calls.
verify(expectedPartitionValueService).getExpectedPartitionValue(expectedPartitionValueKey, offset);
verifyNoMoreInteractions(expectedPartitionValueService);
// Validate the returned object.
assertEquals(expectedPartitionValuesInformation, resultPartitionValueInformation);
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValueInformation 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.api.xml.ExpectedPartitionValueInformation in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testLargeNumberOfExpectedPartitionValues.
@Test
public void testLargeNumberOfExpectedPartitionValues() {
// Define some constants.
final int MAX_PARTITION_VALUES = 1000;
final int LAST_ELEMENT_INDEX = MAX_PARTITION_VALUES - 1;
// Create and persist a partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Add expected partition values to this partition key group.
List<String> testUnsortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues(MAX_PARTITION_VALUES);
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(MAX_PARTITION_VALUES);
ExpectedPartitionValuesCreateRequest createRequest = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, testUnsortedExpectedPartitionValues);
ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.createExpectedPartitionValues(createRequest);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, resultPartitionValuesInformation);
// Validate that the expected partition value entities got created.
assertEquals(testUnsortedExpectedPartitionValues.size(), partitionKeyGroupEntity.getExpectedPartitionValues().size());
// Get expected partition value without an offset.
ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(MAX_PARTITION_VALUES / 2)), null);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(MAX_PARTITION_VALUES / 2), resultPartitionValueInformation);
// Get expected partition value by passing a large positive offset.
resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(0)), LAST_ELEMENT_INDEX);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(LAST_ELEMENT_INDEX), resultPartitionValueInformation);
// Get expected partition value by passing a large negative offset.
resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(LAST_ELEMENT_INDEX)), -LAST_ELEMENT_INDEX);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(0), resultPartitionValueInformation);
// Get a range of expected partition values.
resultPartitionValuesInformation = expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(testSortedExpectedPartitionValues.get(0), testSortedExpectedPartitionValues.get(LAST_ELEMENT_INDEX)));
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, resultPartitionValuesInformation);
// Delete expected partition values from this partition key group.
ExpectedPartitionValuesDeleteRequest deleteRequest = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, testUnsortedExpectedPartitionValues);
ExpectedPartitionValuesInformation deleteResultPartitionValuesInformation = expectedPartitionValueService.deleteExpectedPartitionValues(deleteRequest);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues, deleteResultPartitionValuesInformation);
// Validate that the expected partition value entities got deleted.
assertEquals(0, partitionKeyGroupEntity.getExpectedPartitionValues().size());
}
Aggregations