use of org.finra.herd.model.api.xml.ExpectedPartitionValueKey in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValueTrimParameters.
@Test
public void testGetExpectedPartitionValueTrimParameters() {
// 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 with offset set to 0 and with request parameters padded with whitespace characters.
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
int testExpectedPartitionValueIndex = 3;
ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(addWhitespace(PARTITION_KEY_GROUP), addWhitespace(testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex))), 0);
// Validate the returned object.
expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex), resultPartitionValueInformation);
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValueKey in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuePartitionKeyGroupNoExists.
@Test
public void testGetExpectedPartitionValuePartitionKeyGroupNoExists() {
// Try to perform a get expected partition value using a non-existing partition key group name.
String partitionKeyGroupName = "I_DO_NOT_EXIST";
try {
expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(partitionKeyGroupName, PARTITION_VALUE), null);
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.ExpectedPartitionValueKey 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.ExpectedPartitionValueKey in project herd by FINRAOS.
the class ExpectedPartitionValueDaoTest method testGetExpectedPartitionValueWithOffsetExpectedPartitionValueNoExists.
@Test
public void testGetExpectedPartitionValueWithOffsetExpectedPartitionValueNoExists() {
// Create and persist a partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Create and persist a single test expected partition value.
expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE));
// Validate that we get null back when passing an existing expected partition value but giving an invalid offset.
for (Integer offset : Arrays.asList(-1, 1)) {
assertNull(expectedPartitionValueDao.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, PARTITION_VALUE), offset));
}
}
use of org.finra.herd.model.api.xml.ExpectedPartitionValueKey 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);
}
Aggregations