use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class PartitionKeyGroupDaoImpl method getPartitionKeyGroupByName.
@Override
public PartitionKeyGroupEntity getPartitionKeyGroupByName(String partitionKeyGroupName) {
// 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);
// Create the standard restrictions (i.e. the standard where clauses).
Predicate partitionKeyGroupRestriction = builder.equal(builder.upper(partitionKeyGroupEntity.get(PartitionKeyGroupEntity_.partitionKeyGroupName)), partitionKeyGroupName.toUpperCase());
criteria.select(partitionKeyGroupEntity).where(partitionKeyGroupRestriction);
return executeSingleResultQuery(criteria, String.format("Found more than one \"%s\" partition key group.", partitionKeyGroupName));
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class GetExpectedPartitionValueTest method testGetExpectedPartitionValue.
/**
* This unit test passes all required and optional parameters.
*/
@Test
public void testGetExpectedPartitionValue() throws Exception {
// Create and persist a partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Create and persist a list of expected partition values.
expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
// Get a sorted list of expected partition values.
List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension(GetExpectedPartitionValue.VARIABLE_PARTITION_KEY_GROUP_NAME, "${partitionKeyGroupName}"));
fieldExtensionList.add(buildFieldExtension(GetExpectedPartitionValue.VARIABLE_EXPECTED_PARTITION_VALUE, "${expectedPartitionValue}"));
fieldExtensionList.add(buildFieldExtension(GetExpectedPartitionValue.VARIABLE_OFFSET, "${offset}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter(GetExpectedPartitionValue.VARIABLE_PARTITION_KEY_GROUP_NAME, PARTITION_KEY_GROUP));
parameters.add(buildParameter(GetExpectedPartitionValue.VARIABLE_EXPECTED_PARTITION_VALUE, testSortedExpectedPartitionValues.get(TEST_EXPECTED_PARTITION_VALUE_INDEX)));
parameters.add(buildParameter(GetExpectedPartitionValue.VARIABLE_OFFSET, TEST_OFFSET.toString()));
// Retrieve and validate the expected partition value information.
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GetExpectedPartitionValue.VARIABLE_PARTITION_KEY_GROUP_NAME, PARTITION_KEY_GROUP);
variableValuesToValidate.put(GetExpectedPartitionValue.VARIABLE_EXPECTED_PARTITION_VALUE, testSortedExpectedPartitionValues.get(TEST_EXPECTED_PARTITION_VALUE_INDEX + TEST_OFFSET));
testActivitiServiceTaskSuccess(GetExpectedPartitionValue.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class BusinessObjectFormatDaoTest method testGetBusinessObjectFormatCount.
@Test
public void testGetBusinessObjectFormatCount() {
// Create a partition key group.
PartitionKeyGroupEntity testPartitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
// Create a business object format that uses this partition key group.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY, PARTITION_KEY_GROUP);
// Get the number of business object formats that use this partition key group.
Long result = businessObjectFormatDao.getBusinessObjectFormatCount(testPartitionKeyGroupEntity);
// Validate the results.
assertEquals(Long.valueOf(1L), result);
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class PartitionKeyGroupDaoTest method testGetPartitionKeyGroupByKeyInLowerCase.
@Test
public void testGetPartitionKeyGroupByKeyInLowerCase() {
// Create relative database entities.
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toUpperCase());
// Retrieve partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDao.getPartitionKeyGroupByName(PARTITION_KEY_GROUP.toLowerCase());
// Validate the results.
assertNotNull(partitionKeyGroupEntity);
assertTrue(partitionKeyGroupEntity.getPartitionKeyGroupName().equals(PARTITION_KEY_GROUP.toUpperCase()));
}
use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.
the class PartitionKeyGroupDaoTest method testGetPartitionKeyGroupByKeyInUpperCase.
@Test
public void testGetPartitionKeyGroupByKeyInUpperCase() {
// Create relative database entities.
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toLowerCase());
// Retrieve partition key group entity.
PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDao.getPartitionKeyGroupByName(PARTITION_KEY_GROUP.toUpperCase());
// Validate the results.
assertNotNull(partitionKeyGroupEntity);
assertTrue(partitionKeyGroupEntity.getPartitionKeyGroupName().equals(PARTITION_KEY_GROUP.toLowerCase()));
}
Aggregations