Search in sources :

Example 1 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.

the class AddBusinessObjectDataStorageUnitTest method testAddBusinessObjectDataStorageUnitUsingJsonRequest.

@Test
public void testAddBusinessObjectDataStorageUnitUsingJsonRequest() throws Exception {
    BusinessObjectDataStorageUnitCreateRequest businessObjectDataStorageUnitCreateRequest = businessObjectDataServiceTestHelper.getBusinessObjectDataStorageUnitCreateRequest();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataStorageUnitCreateRequest", "${businessObjectDataStorageUnitCreateRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "json"));
    parameters.add(buildParameter("businessObjectDataStorageUnitCreateRequest", jsonHelper.objectToJson(businessObjectDataStorageUnitCreateRequest)));
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_NOT_NULL);
    testActivitiServiceTaskSuccess(AddBusinessObjectDataStorageUnit.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) BusinessObjectDataStorageUnitCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 2 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.

the class AddEmrStepsTest method testAddHadoopJarStep.

@Test
public void testAddHadoopJarStep() throws Exception {
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    FieldExtension exceptionField = new FieldExtension();
    exceptionField.setFieldName("jarLocation");
    exceptionField.setExpression("${jarLocation}");
    fieldExtensionList.add(exceptionField);
    exceptionField = new FieldExtension();
    exceptionField.setFieldName("mainClass");
    exceptionField.setExpression("${mainClass}");
    fieldExtensionList.add(exceptionField);
    exceptionField = new FieldExtension();
    exceptionField.setFieldName("scriptArguments");
    exceptionField.setExpression("${scriptArguments}");
    fieldExtensionList.add(exceptionField);
    List<Parameter> parameters = new ArrayList<>(getCommonParameters("Hadoop jar Step"));
    Parameter parameter = new Parameter("jarLocation", "s3://test-bucket-managed/app-a/test/hadoop-mapreduce-examples-2.4.0.jar");
    parameters.add(parameter);
    parameter = new Parameter("mainClass", "wordcount");
    parameters.add(parameter);
    parameter = new Parameter("scriptArguments", "arg1|arg/|withpipe|arg2|arg3");
    parameters.add(parameter);
    testActivitiAddEmrStepSuccess(AddEmrHadoopJarStep.class.getCanonicalName(), fieldExtensionList, parameters);
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 3 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.

the class ActivitiDelegateTest method testActivitiReportableError.

/**
 * This method tests the scenario when an error that is not workflow related is throws while workflow is executing an Async type task like Timer. This error
 * is logged as ERROR.
 */
@Test(expected = ActivitiException.class)
public void testActivitiReportableError() throws Exception {
    BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH);
    ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");
    FieldExtension exceptionField = new FieldExtension();
    exceptionField.setFieldName("exceptionToThrow");
    exceptionField.setExpression("${exceptionToThrow}");
    serviceTask.getFieldExtensions().add(exceptionField);
    jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel));
    List<Parameter> parameters = new ArrayList<>();
    Parameter parameter = new Parameter("exceptionToThrow", MockJavaDelegate.EXCEPTION_BPMN_ERROR);
    parameters.add(parameter);
    Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, parameters));
    org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult();
    if (timer != null) {
        executeWithoutLogging(Arrays.asList(ActivitiRuntimeHelper.class, TimerExecuteNestedActivityJobHandler.class), () -> {
            activitiManagementService.executeJob(timer.getId());
        });
    }
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) TimerExecuteNestedActivityJobHandler(org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler) Job(org.finra.herd.model.api.xml.Job) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test) HerdActivitiServiceTaskTest(org.finra.herd.service.activiti.task.HerdActivitiServiceTaskTest)

Example 4 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.

the class AddEmrMasterSecurityGroupTest method testAddEmrMasterSecurityGroup.

@Test
public void testAddEmrMasterSecurityGroup() throws Exception {
    // Create a pipe-separated list of security group IDs.
    final String securityGroupIds = EC2_SECURITY_GROUP_1 + "|" + EC2_SECURITY_GROUP_2;
    // Create EC2 on-demand pricing entities required for testing.
    ec2OnDemandPricingDaoTestHelper.createEc2OnDemandPricingEntities();
    // Create the namespace entity.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
    // Create a trusting AWS account.
    trustingAccountDaoTestHelper.createTrustingAccountEntity(AWS_ACCOUNT_ID, AWS_ROLE_ARN);
    // Create an EMR cluster definition.
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
    // Create an EMR cluster definition override with an AWS account ID.
    EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
    emrClusterDefinitionOverride.setAccountId(AWS_ACCOUNT_ID);
    // Create an EMR cluster.
    emrService.createCluster(new EmrClusterCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME, NO_DRY_RUN, emrClusterDefinitionOverride));
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("emrClusterDefinitionName", "${emrClusterDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("emrClusterName", "${emrClusterName}"));
    fieldExtensionList.add(buildFieldExtension("securityGroupIds", "${securityGroupIds}"));
    fieldExtensionList.add(buildFieldExtension("accountId", "${accountId}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", NAMESPACE));
    parameters.add(buildParameter("emrClusterDefinitionName", EMR_CLUSTER_DEFINITION_NAME));
    parameters.add(buildParameter("emrClusterName", EMR_CLUSTER_NAME));
    parameters.add(buildParameter("securityGroupIds", securityGroupIds));
    parameters.add(buildParameter("accountId", AWS_ACCOUNT_ID));
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(AddEmrMasterSecurityGroup.VARIABLE_EMR_MASTER_SECURITY_GROUPS, securityGroupIds);
    testActivitiServiceTaskSuccess(AddEmrMasterSecurityGroup.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterCreateRequest(org.finra.herd.model.api.xml.EmrClusterCreateRequest) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) FieldExtension(org.activiti.bpmn.model.FieldExtension) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 5 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.

the class UpdateBusinessObjectDataStatusTest method testUpdateBusinessObjectDataStatus.

@Test
public void testUpdateBusinessObjectDataStatus() 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 entity.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Create a business object data status entity.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2);
    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("businessObjectDataStatus", "${businessObjectDataStatus}"));
    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("businessObjectDataStatus", BDATA_STATUS_2));
    // Build the expected response object.
    BusinessObjectDataStatusUpdateResponse expectedBusinessObjectDataStatusUpdateResponse = new BusinessObjectDataStatusUpdateResponse(businessObjectDataKey, BDATA_STATUS_2, BDATA_STATUS);
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(UpdateBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataStatusUpdateResponse));
    testActivitiServiceTaskSuccess(UpdateBusinessObjectDataStatus.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

FieldExtension (org.activiti.bpmn.model.FieldExtension)94 ArrayList (java.util.ArrayList)68 Test (org.junit.Test)67 Parameter (org.finra.herd.model.api.xml.Parameter)64 HashMap (java.util.HashMap)55 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)24 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 Job (org.finra.herd.model.api.xml.Job)11 ServiceTask (org.activiti.bpmn.model.ServiceTask)10 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)10 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)9 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)8 FieldDeclaration (org.activiti.engine.impl.bpmn.parser.FieldDeclaration)4 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 FlowElement (org.activiti.bpmn.model.FlowElement)3 Attribute (org.finra.herd.model.api.xml.Attribute)3 BusinessObjectDataAttributeKeys (org.finra.herd.model.api.xml.BusinessObjectDataAttributeKeys)3