use of org.finra.herd.model.api.xml.PartitionKeyGroupKey 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.PartitionKeyGroupKey in project herd by FINRAOS.
the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValuesInvalidParameters.
@Test
public void testGetExpectedPartitionValuesInvalidParameters() {
// Try to perform a get expected partition values with the start expected partition value being greater than the end expected partition value.
try {
expectedPartitionValueService.getExpectedPartitionValues(new PartitionKeyGroupKey(PARTITION_KEY_GROUP), new PartitionValueRange(PARTITION_VALUE_2, PARTITION_VALUE));
fail("Should throw an IllegalArgumentException when the start expected partition value being greater than the end expected partition value.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("The start expected partition value \"%s\" cannot be greater than the end expected partition value \"%s\".", PARTITION_VALUE_2, PARTITION_VALUE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.PartitionKeyGroupKey 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);
}
use of org.finra.herd.model.api.xml.PartitionKeyGroupKey in project herd by FINRAOS.
the class PartitionKeyGroupDaoTest method testGetPartitionKeyGroups.
@Test
public void testGetPartitionKeyGroups() {
// Create and persist two partition key group entities.
for (PartitionKeyGroupKey partitionKeyGroupKey : getTestPartitionKeyGroupKeys()) {
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(partitionKeyGroupKey.getPartitionKeyGroupName());
}
// Get the list of partition key groups.
List<PartitionKeyGroupKey> resultPartitionKeyGroupKeys = partitionKeyGroupDao.getPartitionKeyGroups();
// Validate the results.
assertNotNull(resultPartitionKeyGroupKeys);
assertTrue(resultPartitionKeyGroupKeys.containsAll(getTestPartitionKeyGroupKeys()));
}
use of org.finra.herd.model.api.xml.PartitionKeyGroupKey in project herd by FINRAOS.
the class PartitionKeyGroupDaoImpl method getPartitionKeyGroups.
@Override
public List<PartitionKeyGroupKey> getPartitionKeyGroups() {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<PartitionKeyGroupEntity> criteria = builder.createQuery(PartitionKeyGroupEntity.class);
// The criteria root is the partition key group.
Root<PartitionKeyGroupEntity> partitionKeyGroupEntity = criteria.from(PartitionKeyGroupEntity.class);
criteria.select(partitionKeyGroupEntity);
List<PartitionKeyGroupKey> partitionKeyGroupKeys = new ArrayList<>();
for (PartitionKeyGroupEntity entity : entityManager.createQuery(criteria).getResultList()) {
PartitionKeyGroupKey partitionKeyGroupKey = new PartitionKeyGroupKey();
partitionKeyGroupKey.setPartitionKeyGroupName(entity.getPartitionKeyGroupName());
partitionKeyGroupKeys.add(partitionKeyGroupKey);
}
return partitionKeyGroupKeys;
}
Aggregations