use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionAlreadyExists.
/**
* This method tests the scenario in which the user tries to register the same job flow twice AlreadyExistsException is expected to be thrown.
*/
@Test(expected = AlreadyExistsException.class)
public void testCreateJobDefinitionAlreadyExists() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create and persist a valid job definition.
JobDefinitionCreateRequest request = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
jobDefinitionService.createJobDefinition(request, false);
// Create the same request again which is an invalid operation, as the workflow exists.
// Following must throw AlreadyExistsException
jobDefinitionService.createJobDefinition(request, false);
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionWithNoParams.
/**
* This method tests the happy path scenario in which no parameters are given.
*/
@Test
public void testCreateJobDefinitionWithNoParams() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create and persist a valid job definition.
JobDefinitionCreateRequest request = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
request.setParameters(null);
// Try creating the job definition.
jobDefinitionService.createJobDefinition(request, false);
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionAssertSuccessWhenFirstTaskNotAsyncable.
/**
* Asserts that create job definition proceeds without exceptions when first task does not support async (ex. events)
*
* @throws Exception
*/
@Test
public void testCreateJobDefinitionAssertSuccessWhenFirstTaskNotAsyncable() 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);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
// Assert no exceptions
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionWithParams.
/**
* This method tests the happy path scenario in which all the parameters including the attributes are given.
*/
@Test
public void testCreateJobDefinitionWithParams() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create and persist a valid job definition.
JobDefinitionCreateRequest request = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
// Add parameters
List<Parameter> parameterEntities = new ArrayList<>();
Parameter parameterEntity = new Parameter();
parameterEntity.setName(ATTRIBUTE_NAME_1_MIXED_CASE);
parameterEntity.setValue(ATTRIBUTE_VALUE_1);
parameterEntities.add(parameterEntity);
request.setParameters(parameterEntities);
// Try creating the job definition.
jobDefinitionService.createJobDefinition(request, false);
}
use of org.finra.herd.model.api.xml.JobDefinitionCreateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionInvalidActivitiXml.
/**
* This method tests the scenario in which the user passes an ill-formatted xml file XMLException is expected to be thrown
*/
@Test(expected = IllegalArgumentException.class)
public void testCreateJobDefinitionInvalidActivitiXml() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create and persist a valid job definition.
JobDefinitionCreateRequest request = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
// Get the XML file for the test workflow.
InputStream xmlStream = resourceLoader.getResource(ACTIVITI_XML_HERD_WORKFLOW_WITH_CLASSPATH).getInputStream();
// Just remove "startEvent" text from the XML file which makes the following line in the XML file as INVALID
// <startEvent id="startevent1" name="Start"></startEvent>
request.setActivitiJobXml(IOUtils.toString(xmlStream).replaceAll("startEvent", ""));
// Try creating the job definition and this must throw XMLException.
jobDefinitionService.createJobDefinition(request, false);
}
Aggregations