Search in sources :

Example 21 with PartitionKeyGroupEntity

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));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) Predicate(javax.persistence.criteria.Predicate)

Example 22 with PartitionKeyGroupEntity

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);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 23 with PartitionKeyGroupEntity

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);
}
Also used : PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) Test(org.junit.Test)

Example 24 with PartitionKeyGroupEntity

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()));
}
Also used : PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) Test(org.junit.Test)

Example 25 with PartitionKeyGroupEntity

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()));
}
Also used : PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) Test(org.junit.Test)

Aggregations

PartitionKeyGroupEntity (org.finra.herd.model.jpa.PartitionKeyGroupEntity)40 Test (org.junit.Test)25 ExpectedPartitionValueKey (org.finra.herd.model.api.xml.ExpectedPartitionValueKey)9 PartitionKeyGroupKey (org.finra.herd.model.api.xml.PartitionKeyGroupKey)9 ExpectedPartitionValuesInformation (org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation)8 ExpectedPartitionValueEntity (org.finra.herd.model.jpa.ExpectedPartitionValueEntity)7 ArrayList (java.util.ArrayList)6 ExpectedPartitionValueInformation (org.finra.herd.model.api.xml.ExpectedPartitionValueInformation)6 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)6 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 HashMap (java.util.HashMap)3 Predicate (javax.persistence.criteria.Predicate)3 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)3 ExpectedPartitionValuesDeleteRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest)3 Order (javax.persistence.criteria.Order)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 ExpectedPartitionValuesCreateRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)2