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);
}
}
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());
}
}
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);
}
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());
}
}
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);
}
Aggregations