use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class CreateBusinessObjectDataAttributeTest method testCreateBusinessObjectDataAttribute.
@Test
public void testCreateBusinessObjectDataAttribute() 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);
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}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataAttributeValue", "${businessObjectDataAttributeValue}"));
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));
parameters.add(buildParameter("businessObjectDataAttributeValue", ATTRIBUTE_VALUE_1));
// 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(SUBPARTITION_VALUES, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getSubPartitionValues());
assertEquals(DATA_VERSION, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectDataVersion());
assertEquals(ATTRIBUTE_NAME_1_MIXED_CASE, businessObjectDataAttribute.getBusinessObjectDataAttributeKey().getBusinessObjectDataAttributeName());
assertEquals(ATTRIBUTE_VALUE_1, businessObjectDataAttribute.getBusinessObjectDataAttributeValue());
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class HerdActivitiServiceTaskTest method createJobAndCheckTaskStatusFailure.
private Job createJobAndCheckTaskStatusFailure(String activitiXml, List<Parameter> parameters, Map<String, Object> variableValuesToValidate) throws Exception {
Job job = jobServiceTestHelper.createJobFromActivitiXml(activitiXml, parameters);
assertNotNull(job);
HistoricProcessInstance hisInstance = activitiHistoryService.createHistoricProcessInstanceQuery().processInstanceId(job.getId()).includeProcessVariables().singleResult();
Map<String, Object> variables = hisInstance.getProcessVariables();
String serviceTaskStatus = (String) variables.get(getServiceTaskVariableName(ActivitiRuntimeHelper.VARIABLE_STATUS));
assertEquals(ActivitiRuntimeHelper.TASK_STATUS_ERROR, serviceTaskStatus);
if (variableValuesToValidate != null) {
for (Map.Entry<String, Object> varEntry : variableValuesToValidate.entrySet()) {
Object wfVariableValue = variables.get(getServiceTaskVariableName(varEntry.getKey()));
Object expectedVariableValue = varEntry.getValue();
if (expectedVariableValue.equals(VARIABLE_VALUE_NOT_NULL)) {
assertNotNull(wfVariableValue);
} else if (expectedVariableValue.equals(VARIABLE_VALUE_IS_NULL)) {
assertNull(wfVariableValue);
} else {
assertEquals(expectedVariableValue, wfVariableValue);
}
}
}
return job;
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class LogVariablesTest method testLogVariablesNoRegex.
@Test
public void testLogVariablesNoRegex() throws Exception {
// Run a job with Activiti XML that will log variables. The XML will log all variables present in the test workflow because no Regex is specified.
Job job = jobServiceTestHelper.createJob(ACTIVITI_XML_LOG_VARIABLES_NO_REGEX_WITH_CLASSPATH);
assertNotNull(job);
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class LogVariablesTest method testLogVariables.
@Test
public void testLogVariables() throws Exception {
// Run a job with Activiti XML that will log variables. The XML will only log 1 of the 2 variables present in the test workflow.
// Since we can't really test what got logged, we'll just ensure that no exceptions were thrown and that the job isn't null.
Job job = jobServiceTestHelper.createJob(ACTIVITI_XML_LOG_VARIABLES_WITH_CLASSPATH);
assertNotNull(job);
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class CheckEmrClusterTest method testCheckClusterByClusterIdStepIdNoActiveStep.
@Test
public void testCheckClusterByClusterIdStepIdNoActiveStep() 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(false, "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");
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);
}
Aggregations