Search in sources :

Example 1 with BusinessObjectDataDdlCollectionResponse

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

the class BusinessObjectDataServiceGenerateBusinessObjectDataDllCollectionTest method testGenerateBusinessObjectDataDdlCollection.

@Test
public void testGenerateBusinessObjectDataDdlCollection() {
    // Prepare database entities required for testing.
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting(AbstractServiceTest.PARTITION_VALUE);
    // Generate DDL for a collection of business object data.
    BusinessObjectDataDdlCollectionResponse resultBusinessObjectDataDdlCollectionResponse = businessObjectDataService.generateBusinessObjectDataDdlCollection(businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlCollectionRequest());
    // Validate the response object.
    assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataDdlCollectionResponse(), resultBusinessObjectDataDdlCollectionResponse);
}
Also used : BusinessObjectDataDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse) Test(org.junit.Test)

Example 2 with BusinessObjectDataDdlCollectionResponse

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

the class BusinessObjectDataRestControllerTest method testGenerateBusinessObjectDataDdlCollection.

@Test
public void testGenerateBusinessObjectDataDdlCollection() {
    // Create a business object data ddl collection request.
    BusinessObjectDataDdlCollectionRequest businessObjectDataDdlCollectionRequest = new BusinessObjectDataDdlCollectionRequest();
    // Create a business object data ddl collection response.
    BusinessObjectDataDdlCollectionResponse businessObjectDataDdlCollectionResponse = new BusinessObjectDataDdlCollectionResponse();
    // Mock the external calls.
    when(businessObjectDataService.generateBusinessObjectDataDdlCollection(businessObjectDataDdlCollectionRequest)).thenReturn(businessObjectDataDdlCollectionResponse);
    // Call the method under test.
    BusinessObjectDataDdlCollectionResponse result = businessObjectDataRestController.generateBusinessObjectDataDdlCollection(businessObjectDataDdlCollectionRequest);
    // Verify the external calls.
    verify(businessObjectDataService).generateBusinessObjectDataDdlCollection(businessObjectDataDdlCollectionRequest);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataDdlCollectionResponse, result);
}
Also used : BusinessObjectDataDdlCollectionRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest) BusinessObjectDataDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse) Test(org.junit.Test)

Example 3 with BusinessObjectDataDdlCollectionResponse

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

the class BusinessObjectDataServiceTestHelper method getExpectedBusinessObjectDataDdlCollectionResponse.

/**
 * Creates an expected generate business object data ddl collection response using hard coded test values.
 *
 * @return the business object data ddl collection response
 */
public BusinessObjectDataDdlCollectionResponse getExpectedBusinessObjectDataDdlCollectionResponse() {
    // Prepare a generate business object data collection response using hard coded test values.
    BusinessObjectDataDdlCollectionResponse businessObjectDataDdlCollectionResponse = new BusinessObjectDataDdlCollectionResponse();
    // Create a list of business object data ddl responses.
    List<BusinessObjectDataDdl> businessObjectDataDdlResponses = new ArrayList<>();
    businessObjectDataDdlCollectionResponse.setBusinessObjectDataDdlResponses(businessObjectDataDdlResponses);
    // Get the actual HIVE DDL expected to be generated.
    String expectedDdl = getExpectedBusinessObjectDataDdl(AbstractServiceTest.PARTITION_VALUE);
    // Create a business object data ddl response.
    BusinessObjectDataDdl expectedBusinessObjectDataDdl = new BusinessObjectDataDdl(AbstractServiceTest.NAMESPACE, AbstractServiceTest.BDEF_NAME, AbstractServiceTest.FORMAT_USAGE_CODE, FileTypeEntity.TXT_FILE_TYPE, AbstractServiceTest.FORMAT_VERSION, Arrays.asList(new PartitionValueFilter(AbstractServiceTest.FIRST_PARTITION_COLUMN_NAME, Arrays.asList(AbstractServiceTest.PARTITION_VALUE), AbstractServiceTest.NO_PARTITION_VALUE_RANGE, AbstractServiceTest.NO_LATEST_BEFORE_PARTITION_VALUE, AbstractServiceTest.NO_LATEST_AFTER_PARTITION_VALUE)), AbstractServiceTest.NO_STANDALONE_PARTITION_VALUE_FILTER, AbstractServiceTest.DATA_VERSION, AbstractServiceTest.NO_STORAGE_NAMES, AbstractServiceTest.STORAGE_NAME, BusinessObjectDataDdlOutputFormatEnum.HIVE_13_DDL, AbstractServiceTest.TABLE_NAME, AbstractServiceTest.NO_CUSTOM_DDL_NAME, expectedDdl);
    // Add two business object ddl responses to the collection response.
    businessObjectDataDdlResponses.add(expectedBusinessObjectDataDdl);
    businessObjectDataDdlResponses.add(expectedBusinessObjectDataDdl);
    // Set the expected DDL collection value.
    businessObjectDataDdlCollectionResponse.setDdlCollection(String.format("%s\n\n%s", expectedDdl, expectedDdl));
    return businessObjectDataDdlCollectionResponse;
}
Also used : BusinessObjectDataDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse) ArrayList(java.util.ArrayList) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter)

Example 4 with BusinessObjectDataDdlCollectionResponse

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

the class BusinessObjectDataServiceImpl method generateBusinessObjectDataDdlCollectionImpl.

/**
 * Retrieves the DDL to initialize the specified type of the database system to perform queries for a collection of business object data in the specified
 * storages.
 *
 * @param businessObjectDataDdlCollectionRequest the business object data DDL collection request
 *
 * @return the business object data DDL information
 */
protected BusinessObjectDataDdlCollectionResponse generateBusinessObjectDataDdlCollectionImpl(BusinessObjectDataDdlCollectionRequest businessObjectDataDdlCollectionRequest) {
    // Perform the validation of the entire request, before we start processing the individual requests that requires the database access.
    validateBusinessObjectDataDdlCollectionRequest(businessObjectDataDdlCollectionRequest);
    // Process the individual requests and build the response.
    BusinessObjectDataDdlCollectionResponse businessObjectDataDdlCollectionResponse = new BusinessObjectDataDdlCollectionResponse();
    List<BusinessObjectDataDdl> businessObjectDataDdlResponses = new ArrayList<>();
    businessObjectDataDdlCollectionResponse.setBusinessObjectDataDdlResponses(businessObjectDataDdlResponses);
    List<String> ddls = new ArrayList<>();
    for (BusinessObjectDataDdlRequest request : businessObjectDataDdlCollectionRequest.getBusinessObjectDataDdlRequests()) {
        // Please note that when calling to process individual ddl requests, we ask to skip the request validation and trimming step.
        BusinessObjectDataDdl businessObjectDataDdl = generateBusinessObjectDataDdlImpl(request, true);
        businessObjectDataDdlResponses.add(businessObjectDataDdl);
        ddls.add(businessObjectDataDdl.getDdl());
    }
    businessObjectDataDdlCollectionResponse.setDdlCollection(StringUtils.join(ddls, "\n\n"));
    return businessObjectDataDdlCollectionResponse;
}
Also used : BusinessObjectDataDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse) BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) ArrayList(java.util.ArrayList) BusinessObjectDataDdl(org.finra.herd.model.api.xml.BusinessObjectDataDdl)

Example 5 with BusinessObjectDataDdlCollectionResponse

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

the class GenerateBusinessObjectDataDdlCollection method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
    String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataDdlCollectionRequest, execution, "BusinessObjectDataDdlCollectionRequest").trim();
    BusinessObjectDataDdlCollectionRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataDdlCollectionRequest.class);
    // Call the business object data service to generate DDL for a collection of business object data.
    BusinessObjectDataDdlCollectionResponse businessObjectDataDdlCollectionResponse = businessObjectDataService.generateBusinessObjectDataDdlCollection(request);
    // Set workflow variable for generated DDL collection.
    setTaskWorkflowVariable(execution, VARIABLE_DDL_COLLECTION, businessObjectDataDdlCollectionResponse.getDdlCollection());
}
Also used : BusinessObjectDataDdlCollectionRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest) BusinessObjectDataDdlCollectionResponse(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse)

Aggregations

BusinessObjectDataDdlCollectionResponse (org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionResponse)5 ArrayList (java.util.ArrayList)2 BusinessObjectDataDdl (org.finra.herd.model.api.xml.BusinessObjectDataDdl)2 BusinessObjectDataDdlCollectionRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest)2 Test (org.junit.Test)2 BusinessObjectDataDdlRequest (org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest)1 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)1