Search in sources :

Example 16 with PartitionKeyGroupEntity

use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.

the class ExpectedPartitionValueServiceTest method testCreateExpectedPartitionValuesExpectedPartitionValueAlreadyExists.

@Test
public void testCreateExpectedPartitionValuesExpectedPartitionValueAlreadyExists() {
    // 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));
    // Try to perform a create using an already existing expected partition value.
    ExpectedPartitionValuesCreateRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesCreateRequest(PARTITION_KEY_GROUP, Arrays.asList(PARTITION_VALUE));
    try {
        expectedPartitionValueService.createExpectedPartitionValues(request);
        fail("Should throw an AlreadyExistsException when expected partition value already exists.");
    } catch (AlreadyExistsException e) {
        assertEquals(String.format("Expected partition value \"%s\" already exists in \"%s\" partition key group.", PARTITION_VALUE, PARTITION_KEY_GROUP), e.getMessage());
    }
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValuesCreateRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest) Test(org.junit.Test)

Example 17 with PartitionKeyGroupEntity

use of org.finra.herd.model.jpa.PartitionKeyGroupEntity 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);
}
Also used : PartitionValueRange(org.finra.herd.model.api.xml.PartitionValueRange) ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) PartitionKeyGroupKey(org.finra.herd.model.api.xml.PartitionKeyGroupKey) Test(org.junit.Test)

Example 18 with PartitionKeyGroupEntity

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

Example 19 with PartitionKeyGroupEntity

use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.

the class ExpectedPartitionValueServiceTest method testDeleteExpectedPartitionValues.

@Test
public void testDeleteExpectedPartitionValues() {
    // 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());
    // Delete expected partition values from this partition key group.
    ExpectedPartitionValuesDeleteRequest request = expectedPartitionValueServiceTestHelper.createExpectedPartitionValuesDeleteRequest(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    ExpectedPartitionValuesInformation resultPartitionValuesInformation = expectedPartitionValueService.deleteExpectedPartitionValues(request);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValuesInformation(PARTITION_KEY_GROUP, expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues(), resultPartitionValuesInformation);
    // Validate that the expected partition value entities got deleted.
    assertEquals(0, partitionKeyGroupEntity.getExpectedPartitionValues().size());
}
Also used : ExpectedPartitionValuesInformation(org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValuesDeleteRequest(org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest) Test(org.junit.Test)

Example 20 with PartitionKeyGroupEntity

use of org.finra.herd.model.jpa.PartitionKeyGroupEntity in project herd by FINRAOS.

the class BusinessObjectFormatDaoTestHelper method createBusinessObjectFormatEntity.

/**
 * Creates and persists a new business object format entity.
 *
 * @return the newly created business object format entity.
 */
public BusinessObjectFormatEntity createBusinessObjectFormatEntity(String namespaceCode, String businessObjectDefinitionName, String businessObjectFormatUsage, String fileType, Integer businessObjectFormatVersion, String businessObjectFormatDescription, Boolean businessObjectFormatLatestVersion, String businessObjectFormatPartitionKey, String partitionKeyGroupName, List<Attribute> attributes, String schemaDelimiterCharacter, String schemaEscapeCharacter, String schemaNullValue, List<SchemaColumn> schemaColumns, List<SchemaColumn> partitionColumns) {
    // Create a business object definition entity if it does not exist.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(namespaceCode, businessObjectDefinitionName));
    if (businessObjectDefinitionEntity == null) {
        businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(namespaceCode, businessObjectDefinitionName, AbstractDaoTest.DATA_PROVIDER_NAME, null);
    }
    // Create a business object format file type entity if it does not exist.
    FileTypeEntity fileTypeEntity = fileTypeDao.getFileTypeByCode(fileType);
    if (fileTypeEntity == null) {
        fileTypeEntity = fileTypeDaoTestHelper.createFileTypeEntity(fileType, null);
    }
    // If partition key group was specified, check if we need to create an entity for it first.
    PartitionKeyGroupEntity partitionKeyGroupEntity = null;
    if (StringUtils.isNotBlank(partitionKeyGroupName)) {
        partitionKeyGroupEntity = partitionKeyGroupDao.getPartitionKeyGroupByName(partitionKeyGroupName);
        if (partitionKeyGroupEntity == null) {
            partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(partitionKeyGroupName);
        }
    }
    return createBusinessObjectFormatEntity(businessObjectDefinitionEntity, businessObjectFormatUsage, fileTypeEntity, businessObjectFormatVersion, businessObjectFormatDescription, businessObjectFormatLatestVersion, businessObjectFormatPartitionKey, partitionKeyGroupEntity, attributes, schemaDelimiterCharacter, schemaEscapeCharacter, schemaNullValue, schemaColumns, partitionColumns);
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity)

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