use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest in project herd by FINRAOS.
the class JobDefinitionRestControllerTest method testUpdateJobDefinition.
@Test
public void testUpdateJobDefinition() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
String activitiJobXml = getActivitiJobXml(NAMESPACE, JOB_NAME);
JobDefinitionUpdateRequest request = new JobDefinitionUpdateRequest(null, activitiJobXml, null, null);
JobDefinition jobDefinition = getJobDefinition(NAMESPACE, JOB_NAME);
when(jobDefinitionService.updateJobDefinition(namespace, jobName, request, true)).thenReturn(jobDefinition);
JobDefinition resultJobDefinition = jobDefinitionRestController.updateJobDefinition(namespace, jobName, new JobDefinitionUpdateRequest(null, activitiJobXml, null, null));
// Verify the external calls.
verify(jobDefinitionService).updateJobDefinition(namespace, jobName, request, true);
verifyNoMoreInteractions(jobDefinitionService);
// Validate the returned object.
assertEquals(jobDefinition, resultJobDefinition);
}
use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinitionWithS3Properties.
@Test
public void testUpdateJobDefinitionWithS3Properties() throws Exception {
S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation();
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create job definition create request using hard coded test values.
JobDefinitionCreateRequest createRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
// 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);
updateRequest.setS3PropertiesLocation(s3PropertiesLocation);
// Update the job definition in the database.
JobDefinition updatedJobDefinition = jobDefinitionService.updateJobDefinition(createRequest.getNamespace(), createRequest.getJobName(), updateRequest, false);
JobDefinitionEntity updatedJobDefinitionEntity = herdDao.findById(JobDefinitionEntity.class, updatedJobDefinition.getId());
// Validate the updated job definition.
assertEquals(new JobDefinition(jobDefinition.getId(), jobDefinition.getNamespace(), jobDefinition.getJobName(), updateRequest.getDescription(), updateRequest.getActivitiJobXml(), updateRequest.getParameters(), s3PropertiesLocation, HerdDaoSecurityHelper.SYSTEM_USER), updatedJobDefinition);
// Validate the updated job definition entity.
Assert.assertEquals("updatedJobDefinitionEntity s3BucketName", s3PropertiesLocation.getBucketName(), updatedJobDefinitionEntity.getS3BucketName());
Assert.assertEquals("updatedJobDefinitionEntity s3ObjectKey", s3PropertiesLocation.getKey(), updatedJobDefinitionEntity.getS3ObjectKey());
}
use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync.
/**
* Asserts that update job definition proceeds without exceptions when first task is set to async
*
* @throws Exception
*/
@Test
public void testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync() 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");
element.setAsynchronous(true);
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);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
jobDefinitionService.updateJobDefinition(namespace, jobName, new JobDefinitionUpdateRequest(null, activitiJobXml, null, null), true);
// Assert no exceptions
}
use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinitionJobNameNoExist.
@Test(expected = ObjectNotFoundException.class)
public void testUpdateJobDefinitionJobNameNoExist() throws Exception {
// Create an update request.
JobDefinitionUpdateRequest updateRequest = createUpdateRequest(jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest());
// Update the process Id to match a valid namespace and invalid job name to pass validation.
updateRequest.setActivitiJobXml(updateRequest.getActivitiJobXml().replace(TEST_ACTIVITI_NAMESPACE_CD + "." + TEST_ACTIVITI_JOB_NAME, TEST_ACTIVITI_NAMESPACE_CD + "." + INVALID_NAME));
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Try to update a job definition that has a namespace that exists, but a job name that doesn't exist.
jobDefinitionService.updateJobDefinition(TEST_ACTIVITI_NAMESPACE_CD, INVALID_NAME, updateRequest, false);
}
use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest in project herd by FINRAOS.
the class JobDefinitionServiceTest method createUpdateRequest.
/**
* Create an update request with a varied set of data that is based on the same data used in the create request.
*
* @param createRequest the create request.
*
* @return the update request.
*/
private JobDefinitionUpdateRequest createUpdateRequest(JobDefinitionCreateRequest createRequest) {
// Create an update request that modifies all data from the create request.
JobDefinitionUpdateRequest updateRequest = new JobDefinitionUpdateRequest();
updateRequest.setDescription(createRequest.getDescription() + "2");
updateRequest.setActivitiJobXml(createRequest.getActivitiJobXml().replace("Unit Test", "Unit Test 2"));
List<Parameter> parameters = new ArrayList<>();
updateRequest.setParameters(parameters);
// Delete the first parameter, update the second parameter, and add a new third parameter.
Parameter parameter = new Parameter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2 + "2");
parameters.add(parameter);
parameter = new Parameter(ATTRIBUTE_NAME_3_MIXED_CASE, ATTRIBUTE_VALUE_3);
parameters.add(parameter);
return updateRequest;
}
Aggregations