Search in sources :

Example 1 with BusinessObjectDataDdlRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.

the class BusinessObjectDataServiceImpl method validateBusinessObjectDataDdlCollectionRequest.

/**
 * Validates a business object data DDL collection request. This method also trims appropriate request parameters.
 *
 * @param businessObjectDataDdlCollectionRequest the request
 *
 * @throws IllegalArgumentException if any validation errors were found
 */
private void validateBusinessObjectDataDdlCollectionRequest(BusinessObjectDataDdlCollectionRequest businessObjectDataDdlCollectionRequest) {
    Assert.notNull(businessObjectDataDdlCollectionRequest, "A business object data DDL collection request must be specified.");
    Assert.isTrue(!CollectionUtils.isEmpty(businessObjectDataDdlCollectionRequest.getBusinessObjectDataDdlRequests()), "At least one business object data DDL request must be specified.");
    for (BusinessObjectDataDdlRequest request : businessObjectDataDdlCollectionRequest.getBusinessObjectDataDdlRequests()) {
        validateBusinessObjectDataDdlRequest(request);
    }
}
Also used : BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)

Example 2 with BusinessObjectDataDdlRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.

the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlPartitionValueRangeFormatWithoutPartitionKeyGroup.

@Test
public void testGenerateBusinessObjectDataDdlPartitionValueRangeFormatWithoutPartitionKeyGroup() {
    // Prepare test data with business object format having no partition key group value specified.
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting(FileTypeEntity.TXT_FILE_TYPE, FIRST_PARTITION_COLUMN_NAME, null, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, UNSORTED_PARTITION_VALUES, SUBPARTITION_VALUES, SCHEMA_DELIMITER_PIPE, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, SCHEMA_NULL_VALUE_BACKSLASH_N, schemaColumnDaoTestHelper.getTestSchemaColumns(), schemaColumnDaoTestHelper.getTestPartitionColumns(), false, CUSTOM_DDL_NAME, true, ALLOW_DUPLICATE_BUSINESS_OBJECT_DATA);
    // Try to generate business object data ddl using partition value range when business object format has no partition key group.
    BusinessObjectDataDdlRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(START_PARTITION_VALUE, END_PARTITION_VALUE, CUSTOM_DDL_NAME);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when generating ddl for a partition value range and " + "business object format has no partition key group.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("A partition key group, which is required to use partition value ranges, " + "is not specified for the business object format {namespace: \"%s\", businessObjectDefinitionName: \"%s\", " + "businessObjectFormatUsage: \"%s\", businessObjectFormatFileType: \"%s\", businessObjectFormatVersion: %d}.", request.getNamespace(), request.getBusinessObjectDefinitionName(), request.getBusinessObjectFormatUsage(), request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion()), e.getMessage());
    }
}
Also used : BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) Test(org.junit.Test)

Example 3 with BusinessObjectDataDdlRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.

the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlTrimParametersPartitionValueRange.

@Test
public void testGenerateBusinessObjectDataDdlTrimParametersPartitionValueRange() {
    // Prepare test data.
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting();
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueProcessDatesForApril2014(PARTITION_KEY_GROUP);
    // Retrieve business object data ddl request with all string values requiring trimming.
    BusinessObjectDataDdlRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(addWhitespace(START_PARTITION_VALUE), addWhitespace(END_PARTITION_VALUE), addWhitespace(CUSTOM_DDL_NAME));
    request.setBusinessObjectDefinitionName(addWhitespace(request.getBusinessObjectDefinitionName()));
    request.setBusinessObjectFormatUsage(addWhitespace(request.getBusinessObjectFormatUsage()));
    request.setBusinessObjectFormatFileType(addWhitespace(request.getBusinessObjectFormatFileType()));
    request.getPartitionValueFilters().get(0).setPartitionKey(addWhitespace(request.getPartitionValueFilters().get(0).getPartitionKey()));
    request.setStorageName(addWhitespace(request.getStorageName()));
    request.setTableName(addWhitespace(request.getTableName()));
    BusinessObjectDataDdl resultDdl = businessObjectDataService.generateBusinessObjectDataDdl(request);
    // Validate the results.
    String expectedDdl = businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataDdl(PARTITION_COLUMNS.length, FIRST_COLUMN_NAME, FIRST_COLUMN_DATA_TYPE, ROW_FORMAT, Hive13DdlGenerator.TEXT_HIVE_FILE_FORMAT, FileTypeEntity.TXT_FILE_TYPE, BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, PROCESS_DATE_AVAILABLE_PARTITION_VALUES, SUBPARTITION_VALUES, false, true, true);
    businessObjectDataServiceTestHelper.validateBusinessObjectDataDdl(request, expectedDdl, resultDdl);
}
Also used : BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl) Test(org.junit.Test)

Example 4 with BusinessObjectDataDdlRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.

the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlMissingRequiredParameters.

@Test
public void testGenerateBusinessObjectDataDdlMissingRequiredParameters() {
    BusinessObjectDataDdlRequest request;
    // Try to retrieve business object data ddl when business object definition name parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectDefinitionName(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when business object definition name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when business object format usage parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectFormatUsage(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when business object format usage parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when business object format file type parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setBusinessObjectFormatFileType(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when business object format file type parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when partition key is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.getPartitionValueFilters().get(0).setPartitionKey(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when partition key is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition key must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when start partition value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(BLANK_TEXT, END_PARTITION_VALUE);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when start partition values is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A start partition value for the partition value range must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when end partition value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(START_PARTITION_VALUE, BLANK_TEXT, null);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when end partition values is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An end partition value for the partition value range must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when partition value list has no partition values specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(new ArrayList<>());
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when partition value list has no partition values specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least one partition value must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when one of the partition values in the partition value list is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.getPartitionValueFilters().get(0).getPartitionValues().add(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when one of the partition values in the partition value list is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A partition value must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when the latest before partition value filter option has no partition value specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(NO_PARTITION_VALUES);
    for (String partitionValue : Arrays.asList(null, BLANK_TEXT)) {
        request.getPartitionValueFilters().get(0).setLatestBeforePartitionValue(new LatestBeforePartitionValue(partitionValue));
        try {
            businessObjectDataService.generateBusinessObjectDataDdl(request);
            fail("Should throw an IllegalArgumentException when the latest before partition value filter option has no partition value specified.");
        } catch (IllegalArgumentException e) {
            assertEquals("A partition value must be specified.", e.getMessage());
        }
    }
    // Try to retrieve business object data ddl when the latest after partition value filter option has no partition value specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(NO_PARTITION_VALUES);
    for (String partitionValue : Arrays.asList(null, BLANK_TEXT)) {
        request.getPartitionValueFilters().get(0).setLatestAfterPartitionValue(new LatestAfterPartitionValue(partitionValue));
        try {
            businessObjectDataService.generateBusinessObjectDataDdl(request);
            fail("Should throw an IllegalArgumentException when the latest after partition value filter option has no partition value specified.");
        } catch (IllegalArgumentException e) {
            assertEquals("A partition value must be specified.", e.getMessage());
        }
    }
    // Try to retrieve business object data ddl when standalone storage name parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when standalone storage name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage name must be specified.", e.getMessage());
    }
    // Try to check business object data availability when standalone storage name parameter value is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setStorageName(null);
    request.setStorageNames(Arrays.asList(BLANK_TEXT));
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when storage name parameter in the list of storage names is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage name must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when output format parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setOutputFormat(null);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when output format parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An output format must be specified.", e.getMessage());
    }
    // Try to retrieve business object data ddl when table name parameter is not specified.
    request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES);
    request.setTableName(BLANK_TEXT);
    try {
        businessObjectDataService.generateBusinessObjectDataDdl(request);
        fail("Should throw an IllegalArgumentException when table name parameter is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A table name must be specified.", e.getMessage());
    }
}
Also used : LatestBeforePartitionValue(org.finra.herd.model.api.xml.LatestBeforePartitionValue) BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) ArrayList(java.util.ArrayList) LatestAfterPartitionValue(org.finra.herd.model.api.xml.LatestAfterPartitionValue) Test(org.junit.Test)

Example 5 with BusinessObjectDataDdlRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.

the class BusinessObjectDataServiceGenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlUpperCaseParameters.

@Test
public void testGenerateBusinessObjectDataDdlUpperCaseParameters() {
    // Prepare test data.
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting();
    // Retrieve business object data ddl request with all parameter values in upper case (except for case-sensitive partition values).
    BusinessObjectDataDdlRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES, CUSTOM_DDL_NAME);
    request.setBusinessObjectDefinitionName(request.getBusinessObjectDefinitionName().toUpperCase());
    request.setBusinessObjectFormatUsage(request.getBusinessObjectFormatUsage().toUpperCase());
    request.setBusinessObjectFormatFileType(request.getBusinessObjectFormatFileType().toUpperCase());
    request.getPartitionValueFilters().get(0).setPartitionKey(request.getPartitionValueFilters().get(0).getPartitionKey().toUpperCase());
    request.setStorageName(request.getStorageName().toUpperCase());
    request.setCustomDdlName(request.getCustomDdlName().toUpperCase());
    BusinessObjectDataDdl resultDdl = businessObjectDataService.generateBusinessObjectDataDdl(request);
    // Validate the results.
    businessObjectDataServiceTestHelper.validateBusinessObjectDataDdl(request, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataDdl(), resultDdl);
}
Also used : BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl) Test(org.junit.Test)

Aggregations

BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)79 Test (org.junit.Test)74 BusinessObjectDataDdl (org.finra.herd.model.api.xml.BusinessObjectDataDdl)47 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)32 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)22 ArrayList (java.util.ArrayList)14 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)13 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)9 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)5 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)5 StorageEntity (org.finra.herd.model.jpa.StorageEntity)5 LatestAfterPartitionValue (org.finra.herd.model.api.xml.LatestAfterPartitionValue)4 LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)4 HashMap (java.util.HashMap)3 Attribute (org.finra.herd.model.api.xml.Attribute)3 BusinessObjectDataDdlCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest)3 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)2