use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class JobServiceTest method testCreateJobDuplicateParameterName.
@Test(expected = IllegalArgumentException.class)
public void testCreateJobDuplicateParameterName() throws Exception {
// Create a job create request using hard coded test values.
JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);
// Add a duplicate parameter.
Parameter parameter = new Parameter();
parameter.setName(addWhitespace(jobCreateRequest.getParameters().get(0).getName().toUpperCase()));
parameter.setValue(jobCreateRequest.getParameters().get(0).getValue());
jobCreateRequest.getParameters().add(parameter);
// Try to create a job.
jobService.createAndStartJob(jobCreateRequest);
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesCreateRequestObjectKeyNotFoundThrows.
/**
* Creates a job where the request's S3 object key does not exist. It should throw a not found exception.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesCreateRequestObjectKeyNotFoundThrows() 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);
jobCreateRequestS3PropertiesLocation.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 '" + jobCreateRequestS3PropertiesLocation.getKey() + "' does not exist.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesValidationBucketNameRequired.
/**
* Creates a job where the request's S3 properties is given, but bucket name is not. It should throw a bad request exception.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesValidationBucketNameRequired() throws Exception {
Parameter jobCreateRequestS3Parameter = new Parameter("name2", "value2");
String s3BucketName = "s3BucketName";
S3PropertiesLocation jobCreateRequestS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobCreationObjectKey", jobCreateRequestS3Parameter);
jobCreateRequestS3PropertiesLocation.setBucketName(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 bucket name must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class JobServiceTestHelper method createJobForCreateCluster.
/**
* Creates a job based on the specified Activiti XML classpath resource location and defines a EMR cluster definition.
*
* @param activitiXmlClasspathResourceName the Activiti XML classpath resource location.
* @param parameters the job parameters.
*
* @return the job.
* @throws Exception if any errors were encountered.
*/
public Job createJobForCreateCluster(String activitiXmlClasspathResourceName, List<Parameter> parameters, String amiVersion) throws Exception {
jobDefinitionServiceTestHelper.createJobDefinition(activitiXmlClasspathResourceName);
NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
String configXml = IOUtils.toString(resourceLoader.getResource(AbstractServiceTest.EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(amiVersion);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, AbstractServiceTest.EMR_CLUSTER_DEFINITION_NAME, configXml);
Parameter parameter = new Parameter("emrClusterDefinitionName", emrClusterDefinitionEntity.getName());
parameters.add(parameter);
parameter = new Parameter("namespace", AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
parameters.add(parameter);
// Start the job synchronously.
return jobService.createAndStartJob(createJobCreateRequest(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD, AbstractServiceTest.TEST_ACTIVITI_JOB_NAME, parameters));
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class JobServiceTestHelper method createJobForCreateClusterForActivitiXml.
/**
* Creates a job based on the specified Activiti XML and defines a EMR cluster definition.
*
* @param activitiXml the Activiti XML.
* @param parameters the job parameters.
*
* @return the job.
* @throws Exception if any errors were encountered.
*/
public Job createJobForCreateClusterForActivitiXml(String activitiXml, List<Parameter> parameters) throws Exception {
jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(activitiXml);
NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, AbstractServiceTest.EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(AbstractServiceTest.EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
Parameter parameter = new Parameter("namespace", namespaceEntity.getCode());
parameters.add(parameter);
parameter = new Parameter("emrClusterDefinitionName", emrClusterDefinitionEntity.getName());
parameters.add(parameter);
parameter = new Parameter("dryRun", null);
parameters.add(parameter);
parameter = new Parameter("contentType", null);
parameters.add(parameter);
parameter = new Parameter("emrClusterDefinitionOverride", null);
parameters.add(parameter);
// Start the job synchronously.
return jobService.createAndStartJob(createJobCreateRequest(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD, AbstractServiceTest.TEST_ACTIVITI_JOB_NAME, parameters));
}
Aggregations