use of org.finra.herd.model.api.xml.S3PropertiesLocation 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.S3PropertiesLocation 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());
}
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation 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);
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3Properties.
/**
* Creates a job where the definition and request has S3 properties. Both parameters should be merged.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3Properties() 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);
Job resultJob = createJobWithParameters(jobDefinitionS3PropertiesLocation, null, jobCreateRequestS3PropertiesLocation, null);
List<Parameter> actualParameters = resultJob.getParameters();
assertParameterEquals(jobDefinitionS3Parameter, actualParameters);
assertParameterEquals(jobCreateRequestS3Parameter, actualParameters);
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JobServiceTest method testSignalJobWithS3Properties.
/**
* Signals job with S3 properties set. Parameters should be populated from the properties.
*
* @throws Exception
*/
@Test
public void testSignalJobWithS3Properties() throws Exception {
jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
Parameter parameter = new Parameter("testName", "testValue");
S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation("s3BucketName", "s3ObjectKey", parameter);
// Start the job.
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
JobSignalRequest jobSignalRequest = new JobSignalRequest(job.getId(), "receivetask1", null, null);
jobSignalRequest.setS3PropertiesLocation(s3PropertiesLocation);
Job signalJob = jobService.signalJob(jobSignalRequest);
assertParameterEquals(parameter, signalJob.getParameters());
}
Aggregations