use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class GenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlJson.
@Test
public void testGenerateBusinessObjectDataDdlJson() throws Exception {
// Prepare test data.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting();
BusinessObjectDataDdlRequest businessObjectDataDdlRequest = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES, CUSTOM_DDL_NAME);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataDdlRequest", "${businessObjectDataDdlRequest}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("contentType", "json"));
parameters.add(buildParameter("businessObjectDataDdlRequest", jsonHelper.objectToJson(businessObjectDataDdlRequest)));
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GenerateBusinessObjectDataDdl.VARIABLE_DDL, VARIABLE_VALUE_NOT_NULL);
executeWithoutLogging(LogVariables.class, () -> {
testActivitiServiceTaskSuccess(GenerateBusinessObjectDataDdl.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
});
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class GenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlXml.
@Test
public void testGenerateBusinessObjectDataDdlXml() throws Exception {
// Prepare test data.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting();
BusinessObjectDataDdlRequest businessObjectDataDdlRequest = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES, CUSTOM_DDL_NAME);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataDdlRequest", "${businessObjectDataDdlRequest}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("contentType", "xml"));
parameters.add(buildParameter("businessObjectDataDdlRequest", xmlHelper.objectToXml(businessObjectDataDdlRequest)));
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GenerateBusinessObjectDataDdl.VARIABLE_DDL, VARIABLE_VALUE_NOT_NULL);
executeWithoutLogging(LogVariables.class, () -> {
testActivitiServiceTaskSuccess(GenerateBusinessObjectDataDdl.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
});
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest 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;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class GenerateBusinessObjectDataDdl method executeImpl.
@Override
public void executeImpl(DelegateExecution execution) throws Exception {
String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataDdlRequest, execution, "businessObjectDataDdlRequest").trim();
BusinessObjectDataDdlRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataDdlRequest.class);
// Generate Ddl.
BusinessObjectDataDdl businessObjectDataDdl = businessObjectDataService.generateBusinessObjectDataDdl(request);
setTaskWorkflowVariable(execution, VARIABLE_DDL, businessObjectDataDdl.getDdl());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceTest method testBusinessObjectDataServiceMethodsNewTx.
/**
* This method is to get the coverage for the business object data service method that starts the new transaction.
*/
@Test
public void testBusinessObjectDataServiceMethodsNewTx() throws Exception {
BusinessObjectDataAvailabilityRequest businessObjectDataAvailabilityRequest = new BusinessObjectDataAvailabilityRequest();
try {
businessObjectDataServiceImpl.checkBusinessObjectDataAvailability(businessObjectDataAvailabilityRequest);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
BusinessObjectDataAvailabilityCollectionRequest businessObjectDataAvailabilityCollectionRequest = new BusinessObjectDataAvailabilityCollectionRequest();
try {
businessObjectDataServiceImpl.checkBusinessObjectDataAvailabilityCollection(businessObjectDataAvailabilityCollectionRequest);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("At least one business object data availability request must be specified.", e.getMessage());
}
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = new BusinessObjectDataCreateRequest();
try {
businessObjectDataServiceImpl.createBusinessObjectData(businessObjectDataCreateRequest);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDataServiceImpl.getBusinessObjectData(new BusinessObjectDataKey(), null, NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDataServiceImpl.generateBusinessObjectDataDdl(new BusinessObjectDataDdlRequest());
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDataServiceImpl.generateBusinessObjectDataDdlCollection(new BusinessObjectDataDdlCollectionRequest());
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("At least one business object data DDL request must be specified.", e.getMessage());
}
try {
businessObjectDataServiceImpl.invalidateUnregisteredBusinessObjectData(new BusinessObjectDataInvalidateUnregisteredRequest());
} catch (IllegalArgumentException e) {
assertEquals("The namespace is required", e.getMessage());
}
try {
businessObjectDataServiceImpl.retryStoragePolicyTransition(new BusinessObjectDataKey(), new BusinessObjectDataRetryStoragePolicyTransitionRequest());
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
try {
businessObjectDataServiceImpl.restoreBusinessObjectData(new BusinessObjectDataKey(), EXPIRATION_IN_DAYS);
} catch (IllegalArgumentException e) {
assertEquals("A namespace must be specified.", e.getMessage());
}
}
Aggregations