use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class JobServiceTest method testCreateJobNoParams.
@Test
public void testCreateJobNoParams() 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(null);
// 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(null);
// Create the job.
Job resultJob = jobService.createAndStartJob(jobCreateRequest);
// expected default parameter
List<Parameter> expectedParameters = Arrays.asList(new Parameter(HERD_WORKFLOW_ENVIRONMENT, configurationHelper.getProperty(ConfigurationValue.HERD_ENVIRONMENT)));
// Validate the results.
assertNotNull(resultJob);
assertNotNull(resultJob.getId());
assertTrue(!resultJob.getId().isEmpty());
assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace());
assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName());
assertTrue(resultJob.getParameters().size() == 1);
assertTrue(expectedParameters.containsAll(resultJob.getParameters()));
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class JobServiceTest method testSignalJob.
@Test
public void testSignalJob() throws Exception {
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
// Start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
// Job should be waiting at Receive task.
Job jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertEquals("receivetask1", jobGet.getCurrentWorkflowStep().getId());
// Signal job to continue.
List<Parameter> signalParameters = new ArrayList<>();
Parameter signalPameter1 = new Parameter("UT_SIGNAL_PARAM_1", "UT_SIGNAL_VALUE_1");
signalParameters.add(signalPameter1);
JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receivetask1", signalParameters, null);
Job signalJob = jobService.signalJob(jobSignalRequest);
assertEquals(JobStatusEnum.RUNNING, signalJob.getStatus());
assertEquals("receivetask1", signalJob.getCurrentWorkflowStep().getId());
assertTrue(signalJob.getParameters().contains(signalPameter1));
// Job should have been completed.
jobGet = jobService.getJob(job.getId(), true);
assertEquals(JobStatusEnum.COMPLETED, jobGet.getStatus());
assertTrue(jobGet.getParameters().contains(signalPameter1));
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class JobServiceTest method testSignalJobNoExists.
@Test
public void testSignalJobNoExists() throws Exception {
// Signal job with job id that does not exist.
try {
jobService.signalJob(new JobSignalRequest("job_does_not_exist", "receivetask1", null, null));
fail("Should throw an ObjectNotFoundException.");
} catch (ObjectNotFoundException ex) {
assertEquals(String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", "job_does_not_exist", "receivetask1"), ex.getMessage());
}
// Signal job with receive task that does not exist.
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
// Start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
try {
// Job should be waiting at Receive task.
Job jobGet = jobService.getJob(job.getId(), false);
assertEquals(JobStatusEnum.RUNNING, jobGet.getStatus());
assertEquals("receivetask1", jobGet.getCurrentWorkflowStep().getId());
jobService.signalJob(new JobSignalRequest(job.getId(), "receivetask_does_not_exist", null, null));
fail("Should throw an ObjectNotFoundException.");
} catch (ObjectNotFoundException ex) {
assertEquals(String.format("No job found for matching job id: \"%s\" and receive task id: \"%s\".", job.getId(), "receivetask_does_not_exist"), ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class JobServiceTest method testCreateJob.
@Test
public void testCreateJob() 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();
// 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);
// Create the job.
Job resultJob = jobService.createAndStartJob(jobCreateRequest);
// Validate the results.
assertNotNull(resultJob);
assertNotNull(resultJob.getId());
assertTrue(!resultJob.getId().isEmpty());
assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace());
assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName());
assertEquals(jobDefinitionCreateRequest.getParameters().size() + jobCreateRequest.getParameters().size() + 1, resultJob.getParameters().size());
List<String> expectedParameters = new ArrayList<>();
expectedParameters.addAll(parametersToStringList(jobDefinitionCreateRequest.getParameters()));
expectedParameters.addAll(parametersToStringList(jobCreateRequest.getParameters()));
expectedParameters.addAll(parametersToStringList(Arrays.asList(new Parameter(HERD_WORKFLOW_ENVIRONMENT, configurationHelper.getProperty(ConfigurationValue.HERD_ENVIRONMENT)))));
List<String> resultParameters = parametersToStringList(resultJob.getParameters());
assertTrue(expectedParameters.containsAll(resultParameters));
assertTrue(resultParameters.containsAll(expectedParameters));
}
use of org.finra.herd.model.api.xml.Job in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesPrecedenceJobRequestParamHighestPrecedence.
/**
* Creates a job where the definition and request has S3 properties and parameters. The job create request's parameter should take precedence if there are
* name clashes.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesPrecedenceJobRequestParamHighestPrecedence() throws Exception {
Parameter jobDefinitionS3Parameter = new Parameter("testName", "testValue1");
Parameter jobDefinitionRequestParameter = new Parameter("testName", "testValue2");
Parameter jobCreateRequestS3Parameter = new Parameter("testName", "testValue3");
Parameter jobCreateRequestParameter = new Parameter("testName", "expectedValue");
String s3BucketName = "s3BucketName";
S3PropertiesLocation jobDefinitionS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobDefinitionObjectKey", jobDefinitionS3Parameter);
S3PropertiesLocation jobCreateRequestS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobCreateRequestObjectKey", jobCreateRequestS3Parameter);
Job resultJob = createJobWithParameters(jobDefinitionS3PropertiesLocation, Arrays.asList(jobDefinitionRequestParameter), jobCreateRequestS3PropertiesLocation, Arrays.asList(jobCreateRequestParameter));
List<Parameter> actualParameters = resultJob.getParameters();
assertParameterEquals(jobCreateRequestParameter, actualParameters);
}
Aggregations