Search in sources :

Example 71 with FieldExtension

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

the class CheckEmrClusterTest method testCheckClusterByClusterIdStepIdRequestedStepHasNoId.

/**
 * This method tests the check EMR cluster activiti task with cluster Id and step Id specified and requested step contains no id in response
 */
@Test
public void testCheckClusterByClusterIdStepIdRequestedStepHasNoId() throws Exception {
    List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
    FieldExtension fieldExtension = new FieldExtension();
    fieldExtension.setFieldName("emrStepId");
    fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
    fieldExtensions.add(fieldExtension);
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(new Parameter("clusterName", "testCluster1"));
    parameters.add(new Parameter("hiveStepName", MockEmrOperationsImpl.MOCK_STEP_WITHOUT_ID_NAME));
    parameters.add(new Parameter("hiveScriptLocation", "a_hive_step_location"));
    parameters.add(new Parameter("shellStepName", MockEmrOperationsImpl.MOCK_STEP_RUNNING_NAME));
    parameters.add(new Parameter("shellScriptLocation", "a_shell_step_location"));
    parameters.add(new Parameter("verbose", "false"));
    parameters.add(new Parameter("retrieveInstanceFleets", "false"));
    // Run a job with Activiti XML that will start cluster, check status and terminate.
    Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), parameters);
    assertNotNull(job);
    HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
    Map<String, Object> variables = hisInstance.getProcessVariables();
    String hiveStepId = (String) variables.get("addHiveStepServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "emrStepId");
    assertNotNull(hiveStepId);
    String emrStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_id");
    assertNull(emrStepId);
    String emrStepJarLocation = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_jarLocation");
    assertNull(emrStepJarLocation);
    String shellStepId = (String) variables.get("addShellStepServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "emrStepId");
    assertNotNull(shellStepId);
    String activeStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "activeStep_id");
    assertEquals(shellStepId, activeStepId);
    String activeStepJarLocation = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "activeStep_jarLocation");
    assertNull(activeStepJarLocation);
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) 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) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 72 with FieldExtension

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

the class CheckEmrClusterTest method testCheckClusterByClusterIdStepIdActiveStepHasNoId.

@Test
public void testCheckClusterByClusterIdStepIdActiveStepHasNoId() throws Exception {
    List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
    FieldExtension fieldExtension = new FieldExtension();
    fieldExtension.setFieldName("emrStepId");
    fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
    fieldExtensions.add(fieldExtension);
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(new Parameter("clusterName", "testCluster1"));
    parameters.add(new Parameter("hiveStepName", "a_hive_step"));
    parameters.add(new Parameter("hiveScriptLocation", "a_hive_step_location"));
    parameters.add(new Parameter("shellStepName", MockEmrOperationsImpl.MOCK_STEP_RUNNING_WITHOUT_ID_NAME));
    parameters.add(new Parameter("shellScriptLocation", "a_shell_step_location"));
    parameters.add(new Parameter("verbose", "false"));
    parameters.add(new Parameter("retrieveInstanceFleets", "false"));
    // Run a job with Activiti XML that will start cluster, check status and terminate.
    Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), parameters);
    assertNotNull(job);
    HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
    Map<String, Object> variables = hisInstance.getProcessVariables();
    String hiveStepId = (String) variables.get("addHiveStepServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "emrStepId");
    assertNotNull(hiveStepId);
    String emrStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_id");
    assertEquals(hiveStepId, emrStepId);
    String emrStepJarLocation = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "step_jarLocation");
    assertNull(emrStepJarLocation);
    String activeStepId = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "activeStep_id");
    assertNull(activeStepId);
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) 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) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 73 with FieldExtension

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

the class AddBusinessObjectDataStorageUnitTest method testAddBusinessObjectDataStorageUnitUsingXmlRequest.

@Test
public void testAddBusinessObjectDataStorageUnitUsingXmlRequest() 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", "xml"));
    parameters.add(buildParameter("businessObjectDataStorageUnitCreateRequest", xmlHelper.objectToXml(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 74 with FieldExtension

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

the class AddEmrStepsTest method getScriptStepsFieldExtension.

private List<FieldExtension> getScriptStepsFieldExtension() {
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    FieldExtension exceptionField = new FieldExtension();
    exceptionField.setFieldName("scriptLocation");
    exceptionField.setExpression("${scriptLocation}");
    fieldExtensionList.add(exceptionField);
    exceptionField = new FieldExtension();
    exceptionField.setFieldName("scriptArguments");
    exceptionField.setExpression("${scriptArguments}");
    fieldExtensionList.add(exceptionField);
    return fieldExtensionList;
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList)

Example 75 with FieldExtension

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

the class ActivitiDelegateTest method testDelegateRuntimeError.

/**
 * This method tests the scenario where a RuntimeException occurs but not thrown by java delegate.
 */
@Test
public void testDelegateRuntimeError() throws Exception {
    BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_WORKFLOW);
    ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");
    serviceTask.setImplementation(MockJavaDelegate.class.getCanonicalName());
    FieldExtension exceptionField = new FieldExtension();
    exceptionField.setFieldName("exceptionToThrow");
    exceptionField.setExpression("${exceptionToThrow}");
    serviceTask.getFieldExtensions().clear();
    serviceTask.getFieldExtensions().add(exceptionField);
    List<Parameter> parameters = new ArrayList<>();
    Parameter parameter = new Parameter("exceptionToThrow", MockJavaDelegate.EXCEPTION_RUNTIME);
    parameters.add(parameter);
    executeWithoutLogging(Arrays.asList(ActivitiRuntimeHelper.class, BaseJavaDelegate.class), () -> {
        jobServiceTestHelper.createJobFromActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel), parameters);
    });
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) BaseJavaDelegate(org.finra.herd.service.activiti.task.BaseJavaDelegate) MockJavaDelegate(org.finra.herd.service.activiti.task.MockJavaDelegate) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test) HerdActivitiServiceTaskTest(org.finra.herd.service.activiti.task.HerdActivitiServiceTaskTest)

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