use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesWithInvalidUnicodeThrows.
/**
* A Java Properties file is invalid when there is an invalid unicode reference. The service should throw a friendly error message when such case happens.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesWithInvalidUnicodeThrows() throws Exception {
Parameter jobCreateRequestS3Parameter = new Parameter("name2", "value2\\uxxxx");
String s3BucketName = "s3BucketName";
S3PropertiesLocation jobCreateRequestS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobCreationObjectKey", jobCreateRequestS3Parameter);
String bucketName = jobCreateRequestS3PropertiesLocation.getBucketName();
String key = jobCreateRequestS3PropertiesLocation.getKey();
try {
createJobWithParameters(null, null, jobCreateRequestS3PropertiesLocation, null);
Assert.fail("expected IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass());
Assert.assertEquals("thrown exception message", "The properties file in S3 bucket '" + bucketName + "' and key '" + key + "' is invalid.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Parameter 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.Parameter in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesDefinitionObjectKeyNotFoundThrows.
/**
* Creates a job where the definition's S3 object key does not exist. It should throw a not found exception.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesDefinitionObjectKeyNotFoundThrows() throws Exception {
Parameter jobDefinitionS3Parameter = new Parameter("name1", "value1");
Parameter jobCreateRequestS3Parameter = new Parameter("name2", "value2");
String s3BucketName = "s3BucketName";
S3PropertiesLocation jobDefinitionS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobDefinitionObjectKey", jobDefinitionS3Parameter);
S3PropertiesLocation jobCreateRequestS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobCreationObjectKey", jobCreateRequestS3Parameter);
jobDefinitionS3PropertiesLocation.setKey("NOT_FOUND");
try {
createJobWithParameters(jobDefinitionS3PropertiesLocation, null, jobCreateRequestS3PropertiesLocation, null);
Assert.fail("expected ObjectNotFoundException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", ObjectNotFoundException.class, e.getClass());
Assert.assertEquals("thrown exception message", "Specified S3 object key '" + jobDefinitionS3PropertiesLocation.getKey() + "' does not exist.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Parameter 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.Parameter in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesValidationObjectKeyRequired.
/**
* Creates a job where the request's S3 properties is given, but object key is not. It should throw a bad request exception.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesValidationObjectKeyRequired() throws Exception {
Parameter jobCreateRequestS3Parameter = new Parameter("name2", "value2");
String s3BucketName = "s3BucketName";
S3PropertiesLocation jobCreateRequestS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobCreationObjectKey", jobCreateRequestS3Parameter);
jobCreateRequestS3PropertiesLocation.setKey(null);
try {
createJobWithParameters(null, null, jobCreateRequestS3PropertiesLocation, null);
Assert.fail("expected IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass());
Assert.assertEquals("thrown exception message", "S3 properties location object key must be specified.", e.getMessage());
}
}
Aggregations