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);
}
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);
}
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);
}
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;
}
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);
});
}
Aggregations