Search in sources :

Example 51 with Parameter

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

the class CreateBusinessObjectDataAttributeTest method testCreateBusinessObjectDataAttributeMissingOptionalParameters.

@Test
public void testCreateBusinessObjectDataAttributeMissingOptionalParameters() throws Exception {
    // Create a business object data key without sub-partition values.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data entity.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataAttributeName", "${businessObjectDataAttributeName}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
    parameters.add(buildParameter("businessObjectDataAttributeName", ATTRIBUTE_NAME_1_MIXED_CASE));
    // Run the activiti task.
    String activitiXml = buildActivitiXml(CreateBusinessObjectDataAttribute.class.getCanonicalName(), fieldExtensionList);
    Job job = jobServiceTestHelper.createJobFromActivitiXml(activitiXml, parameters);
    assertNotNull(job);
    HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
    Map<String, Object> variables = hisInstance.getProcessVariables();
    // Validate status.
    String serviceTaskStatus = (String) variables.get(getServiceTaskVariableName(ActivitiRuntimeHelper.VARIABLE_STATUS));
    assertEquals(ActivitiRuntimeHelper.TASK_STATUS_SUCCESS, serviceTaskStatus);
    // Retrieve JSON response.
    String jsonResponse = (String) variables.get(getServiceTaskVariableName(BaseJavaDelegate.VARIABLE_JSON_RESPONSE));
    ObjectMapper objectMapper = new ObjectMapper();
    BusinessObjectDataAttribute businessObjectDataAttribute = objectMapper.readValue(jsonResponse.getBytes(), BusinessObjectDataAttribute.class);
    // Validate JSON response.
    assertEquals(BDEF_NAMESPACE, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getNamespace());
    assertEquals(BDEF_NAME, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectDefinitionName());
    assertEquals(FORMAT_USAGE_CODE, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectFormatUsage());
    assertEquals(FORMAT_FILE_TYPE_CODE, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectFormatFileType());
    assertEquals(FORMAT_VERSION, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectFormatVersion());
    assertEquals(PARTITION_VALUE, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getPartitionValue());
    assertEquals(NO_SUBPARTITION_VALUES, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getSubPartitionValues());
    assertEquals(DATA_VERSION, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectDataVersion());
    assertEquals(ATTRIBUTE_NAME_1_MIXED_CASE, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectDataAttributeName());
    assertNull(businessObjectDataAttribute.getBusinessObjectDataAttributeValue());
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataAttribute(org.finra.herd.model.api.xml.BusinessObjectDataAttribute) FieldExtension(org.activiti.bpmn.model.FieldExtension) Parameter(org.finra.herd.model.api.xml.Parameter) Job(org.finra.herd.model.api.xml.Job) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 52 with Parameter

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

the class CreateEmrClusterTest method createJob.

private Map<String, Object> createJob(String clusterName, String dryRun, String contentType, String emrClusterDefinitionOverride) throws Exception {
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(new Parameter("clusterName", clusterName));
    parameters.add(new Parameter("dryRun", dryRun));
    parameters.add(new Parameter("contentType", contentType));
    parameters.add(new Parameter("emrClusterDefinitionOverride", emrClusterDefinitionOverride));
    // Run a job with Activiti XML that will start cluster.
    Job job = jobServiceTestHelper.createJobForCreateCluster(ACTIVITI_XML_CREATE_CLUSTER_WITH_CLASSPATH, parameters);
    assertNotNull(job);
    HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
    return hisInstance.getProcessVariables();
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Job(org.finra.herd.model.api.xml.Job)

Example 53 with Parameter

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

the class DeleteBusinessObjectDataAttributeTest method testDeleteBusinessObjectDataAttribute.

@Test
public void testDeleteBusinessObjectDataAttribute() throws Exception {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data attribute key.
    BusinessObjectDataAttributeKey businessObjectDataAttributeKey = businessObjectDataAttributeHelper.getBusinessObjectDataAttributeKey(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE);
    // Create a business object data attribute entity.
    BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
    // Validate that the business object data attribute is created.
    assertNotNull(businessObjectDataAttributeDao.getBusinessObjectDataAttributeByKey(businessObjectDataAttributeKey));
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataAttributeName", "${businessObjectDataAttributeName}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("subPartitionValues", herdStringHelper.buildStringWithDefaultDelimiter(SUBPARTITION_VALUES)));
    parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
    parameters.add(buildParameter("businessObjectDataAttributeName", ATTRIBUTE_NAME_1_MIXED_CASE));
    // Build the expected response object.
    BusinessObjectDataAttribute expectedBusinessObjectDataAttribute = new BusinessObjectDataAttribute(businessObjectDataAttributeEntity.getId(), businessObjectDataAttributeKey, ATTRIBUTE_VALUE_1);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(DeleteBusinessObjectDataAttribute.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataAttribute));
    testActivitiServiceTaskSuccess(DeleteBusinessObjectDataAttribute.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
    // Validate that the business object data attribute is deleted.
    assertNull(businessObjectDataAttributeDao.getBusinessObjectDataAttributeByKey(businessObjectDataAttributeKey));
}
Also used : BusinessObjectDataAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity) HashMap(java.util.HashMap) BusinessObjectDataAttributeKey(org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataAttribute(org.finra.herd.model.api.xml.BusinessObjectDataAttribute) FieldExtension(org.activiti.bpmn.model.FieldExtension) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 54 with Parameter

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

the class DeleteBusinessObjectDataAttributeTest method testDeleteBusinessObjectDataAttributeMissingOptionalParametersSubPartitionValuesAsEmptyString.

@Test
public void testDeleteBusinessObjectDataAttributeMissingOptionalParametersSubPartitionValuesAsEmptyString() throws Exception {
    // Create a business object data key without sub-partition values.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
    // Create a business object data attribute key.
    BusinessObjectDataAttributeKey businessObjectDataAttributeKey = businessObjectDataAttributeHelper.getBusinessObjectDataAttributeKey(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE);
    // Create a business object data attribute entity.
    BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
    // Validate that the business object data attribute is created.
    assertNotNull(businessObjectDataAttributeDao.getBusinessObjectDataAttributeByKey(businessObjectDataAttributeKey));
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataAttributeName", "${businessObjectDataAttributeName}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("subPartitionValues", EMPTY_STRING));
    parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
    parameters.add(buildParameter("businessObjectDataAttributeName", ATTRIBUTE_NAME_1_MIXED_CASE));
    // Build the expected response object.
    BusinessObjectDataAttribute expectedBusinessObjectDataAttribute = new BusinessObjectDataAttribute(businessObjectDataAttributeEntity.getId(), businessObjectDataAttributeHelper.getBusinessObjectDataAttributeKey(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(DeleteBusinessObjectDataAttribute.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataAttribute));
    testActivitiServiceTaskSuccess(DeleteBusinessObjectDataAttribute.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
    // Validate that the business object data attribute is deleted.
    assertNull(businessObjectDataAttributeDao.getBusinessObjectDataAttributeByKey(businessObjectDataAttributeKey));
}
Also used : BusinessObjectDataAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity) HashMap(java.util.HashMap) BusinessObjectDataAttributeKey(org.finra.herd.model.api.xml.BusinessObjectDataAttributeKey) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataAttribute(org.finra.herd.model.api.xml.BusinessObjectDataAttribute) FieldExtension(org.activiti.bpmn.model.FieldExtension) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 55 with Parameter

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

the class ExecuteJdbcTest method testExecuteJdbcWithReceiveTask.

/**
 * Asserts that the task executes asynchronously when receiveTaskId is specified.
 * <p/>
 * This is a very special test case which involves multithreading and transactions, therefore we cannot use the standard test methods we have. The
 * transaction MUST BE DISABLED for this test to work correctly - since we have 2 threads which both access the database, if we run transactionally, the
 * threads cannot share information.
 * <p/>
 * TODO this test could be made generic once we have async support for other tasks.
 */
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void testExecuteJdbcWithReceiveTask() throws Exception {
    // Create and persist a test job definition.
    executeJdbcTestHelper.prepareHerdDatabaseForExecuteJdbcWithReceiveTaskTest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, "classpath:org/finra/herd/service/testActivitiWorkflowExecuteJdbcTaskWithReceiveTask.bpmn20.xml");
    try {
        // Create a JDBC execution request.
        JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
        // Create and initialize a list of parameters.
        List<Parameter> parameters = new ArrayList<>();
        parameters.add(new Parameter("contentType", "xml"));
        parameters.add(new Parameter("jdbcExecutionRequest", xmlHelper.objectToXml(jdbcExecutionRequest)));
        // Get a job create request.
        JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);
        jobCreateRequest.setParameters(parameters);
        // Start the job.
        Job jobStartResponse = jobService.createAndStartJob(jobCreateRequest);
        // Wait for the process to finish
        waitUntilAllProcessCompleted();
        // Validate that the job is completed.
        Job jobGetResponse = jobService.getJob(jobStartResponse.getId(), true);
        assertEquals(JobStatusEnum.COMPLETED, jobGetResponse.getStatus());
        // Validate the task status.
        assertTrue(jobGetResponse.getParameters().contains(new Parameter("service_taskStatus", "SUCCESS")));
        // Validate the JDBC execution response.
        JdbcExecutionResponse expectedJdbcExecutionResponse = new JdbcExecutionResponse();
        JdbcStatement originalJdbcStatement = jdbcExecutionRequest.getStatements().get(0);
        JdbcStatement expectedJdbcStatement = new JdbcStatement();
        expectedJdbcStatement.setType(originalJdbcStatement.getType());
        expectedJdbcStatement.setSql(originalJdbcStatement.getSql());
        expectedJdbcStatement.setStatus(JdbcStatementStatus.SUCCESS);
        expectedJdbcStatement.setResult("1");
        expectedJdbcExecutionResponse.setStatements(Arrays.asList(expectedJdbcStatement));
        Parameter expectedJdbcExecutionResponseParameter = new Parameter("service_jsonResponse", jsonHelper.objectToJson(expectedJdbcExecutionResponse));
        assertTrue(jobGetResponse.getParameters().contains(expectedJdbcExecutionResponseParameter));
    } finally {
        // Clean up the Herd database.
        executeJdbcTestHelper.cleanUpHerdDatabaseAfterExecuteJdbcWithReceiveTaskTest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);
        // Clean up the Activiti.
        deleteActivitiDeployments();
    }
}
Also used : JdbcStatement(org.finra.herd.model.api.xml.JdbcStatement) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Job(org.finra.herd.model.api.xml.Job) JdbcExecutionRequest(org.finra.herd.model.api.xml.JdbcExecutionRequest) JdbcExecutionResponse(org.finra.herd.model.api.xml.JdbcExecutionResponse) JobCreateRequest(org.finra.herd.model.api.xml.JobCreateRequest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Parameter (org.finra.herd.model.api.xml.Parameter)148 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)98 FieldExtension (org.activiti.bpmn.model.FieldExtension)64 HashMap (java.util.HashMap)61 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)30 Job (org.finra.herd.model.api.xml.Job)30 SystemJobRunRequest (org.finra.herd.model.api.xml.SystemJobRunRequest)20 SystemJobRunResponse (org.finra.herd.model.api.xml.SystemJobRunResponse)14 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)13 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)13 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)8 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)7 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 JobAction (org.finra.herd.model.api.xml.JobAction)6 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)6 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5