use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTestHelper method createJobDefinition.
/**
* Creates a job definition based on the specified Activiti XML classpath resource location.
*
* @param activitiXmlClasspathResourceName the Activiti XML classpath resource location.
*
* @return the job definition.
* @throws Exception if any errors were encountered.
*/
public JobDefinition createJobDefinition(String activitiXmlClasspathResourceName) throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
// Create and persist a valid job definition.
JobDefinitionCreateRequest jobDefinitionCreateRequest = createJobDefinitionCreateRequest(activitiXmlClasspathResourceName);
JobDefinition jobDefinition = jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);
// Validate the returned object against the input.
assertEquals(new JobDefinition(jobDefinition.getId(), jobDefinitionCreateRequest.getNamespace(), jobDefinitionCreateRequest.getJobName(), jobDefinitionCreateRequest.getDescription(), jobDefinitionCreateRequest.getActivitiJobXml(), jobDefinitionCreateRequest.getParameters(), jobDefinitionCreateRequest.getS3PropertiesLocation(), HerdDaoSecurityHelper.SYSTEM_USER), jobDefinition);
return jobDefinition;
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobServiceTest method createJobWithParameters.
/**
* Creates a new job definition, and a job using the default values and given parameters configurations.
*
* @param jobDefinitionS3PropertiesLocation the S3 properties location for the job definition
* @param jobDefinitionParameters the job definition parameters
* @param jobCreateRequestS3PropertiesLocation the S3 properties location for the job create request
* @param jobCreateRequestParameters the job create request parameters
*
* @return the job
* @throws Exception
*/
private Job createJobWithParameters(S3PropertiesLocation jobDefinitionS3PropertiesLocation, List<Parameter> jobDefinitionParameters, S3PropertiesLocation jobCreateRequestS3PropertiesLocation, List<Parameter> jobCreateRequestParameters) throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create a job definition create request using hard coded test values.
JobDefinitionCreateRequest jobDefinitionCreateRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
jobDefinitionCreateRequest.setParameters(jobDefinitionParameters);
jobDefinitionCreateRequest.setS3PropertiesLocation(jobDefinitionS3PropertiesLocation);
// Create the job definition.
jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);
// Create a job create request using hard coded test values.
JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);
jobCreateRequest.setParameters(jobCreateRequestParameters);
jobCreateRequest.setS3PropertiesLocation(jobCreateRequestS3PropertiesLocation);
// Create the job.
return jobService.createAndStartJob(jobCreateRequest);
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method createJobDefinition.
/**
* Creates a new standard job definition.
*
* @return the created job definition.
* @throws Exception if any problems were encountered.
*/
private JobDefinition createJobDefinition() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create job definition create request using hard coded test values.
JobDefinitionCreateRequest request = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
// Create the job definition in the database.
JobDefinition jobDefinition = jobDefinitionService.createJobDefinition(request, false);
// Validate the created job definition.
validateJobDefinition(jobDefinition);
return jobDefinition;
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinition.
@Test
public void testUpdateJobDefinition() throws Exception {
// Create job definition create request using hard coded test values.
JobDefinitionCreateRequest createRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
// Set 2 distinct parameters.
List<Parameter> parameters = new ArrayList<>();
createRequest.setParameters(parameters);
Parameter parameter = new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
parameters.add(parameter);
parameter = new Parameter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2);
parameters.add(parameter);
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create the job definition in the database.
JobDefinition jobDefinition = jobDefinitionService.createJobDefinition(createRequest, false);
// Create an update request with a varied set of data that is based on the same data used in the create request.
JobDefinitionUpdateRequest updateRequest = createUpdateRequest(createRequest);
// Update the job definition in the database.
JobDefinition updatedJobDefinition = jobDefinitionService.updateJobDefinition(createRequest.getNamespace(), createRequest.getJobName(), updateRequest, false);
// Validate the updated job definition.
assertEquals(new JobDefinition(jobDefinition.getId(), jobDefinition.getNamespace(), jobDefinition.getJobName(), updateRequest.getDescription(), updateRequest.getActivitiJobXml(), updateRequest.getParameters(), jobDefinition.getS3PropertiesLocation(), HerdDaoSecurityHelper.SYSTEM_USER), updatedJobDefinition);
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionAssertThrowErrorWhenFirstTaskNotAsync.
/**
* Asserts that create job definition proceeds throws an exception when the first task is not async
*
* @throws Exception
*/
@Test
public void testCreateJobDefinitionAssertThrowErrorWhenFirstTaskNotAsync() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId(namespace + '.' + jobName);
{
StartEvent element = new StartEvent();
element.setId("start");
process.addFlowElement(element);
}
{
ScriptTask element = new ScriptTask();
element.setId("script");
element.setScriptFormat("js");
element.setScript("// do nothing");
process.addFlowElement(element);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "script"));
process.addFlowElement(new SequenceFlow("script", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
try {
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("Element with id \"script\" must be set to activiti:async=true. All tasks which start the workflow must be asynchronous to prevent " + "certain undesired transactional behavior, such as records of workflow not being saved on errors. Please refer to Activiti and herd " + "documentations for details.", e.getMessage());
}
}
Aggregations