use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.
the class CheckEmrClusterTest method testCheckClusterByClusterIdStepId.
/**
* This method tests the check EMR cluster activiti task with cluster Id and step Id specified
*/
@Test
public void testCheckClusterByClusterIdStepId() throws Exception {
List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("emrStepId");
fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
fieldExtensions.add(fieldExtension);
// Run a job with Activiti XML that will start cluster, check status and terminate.
Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), getParameters(true, "false", "false"));
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");
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 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 testCheckClusterByClusterIdStepIdVerbose.
/**
* This method tests the check EMR cluster activiti task with cluster Id and step Id specified
*/
@Test
public void testCheckClusterByClusterIdStepIdVerbose() throws Exception {
// Run a job with Activiti XML that will start cluster, check status and terminate.
List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("emrStepId");
fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
fieldExtensions.add(fieldExtension);
Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), getParameters(true, "true", "false"));
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");
assertNotNull(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");
assertNotNull(activeStepJarLocation);
}
use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.
the class CheckEmrClusterTest method testCheckClusterByRetrieveInstanceFleets.
@Test
public void testCheckClusterByRetrieveInstanceFleets() throws Exception {
// Run a job with Activiti XML that will start cluster, check status and terminate.
List<FieldExtension> fieldExtensions = getOptionalFieldExtensions();
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("emrStepId");
fieldExtension.setExpression("${addHiveStepServiceTask_emrStepId}");
fieldExtensions.add(fieldExtension);
Job job = jobServiceTestHelper.createJobForCreateClusterForActivitiXml(getCheckClusterActivitiXml(fieldExtensions), getParameters(true, "true", "true"));
assertNotNull(job);
HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
Map<String, Object> variables = hisInstance.getProcessVariables();
String emrClusterInstanceFleetJson = (String) variables.get("checkClusterServiceTask" + ActivitiRuntimeHelper.TASK_VARIABLE_MARKER + "instance_fleets");
assertNotNull(emrClusterInstanceFleetJson);
}
use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.
the class CreateBusinessObjectDataAttributeTest method testCreateBusinessObjectDataAttributeMissingOptionalParametersSubPartitionValuesAsEmptyString.
@Test
public void testCreateBusinessObjectDataAttributeMissingOptionalParametersSubPartitionValuesAsEmptyString() 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("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));
// 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());
}
use of org.activiti.bpmn.model.FieldExtension 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());
}
Aggregations