Search in sources :

Example 76 with Parameter

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);
}
Also used : Parameter(org.finra.herd.model.api.xml.Parameter) JobCreateRequest(org.finra.herd.model.api.xml.JobCreateRequest) Test(org.junit.Test)

Example 77 with Parameter

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());
    }
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Parameter(org.finra.herd.model.api.xml.Parameter) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Test(org.junit.Test)

Example 78 with Parameter

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());
    }
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) Parameter(org.finra.herd.model.api.xml.Parameter) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Test(org.junit.Test)

Example 79 with Parameter

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));
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) Parameter(org.finra.herd.model.api.xml.Parameter) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity)

Example 80 with Parameter

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));
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) Parameter(org.finra.herd.model.api.xml.Parameter) EmrClusterDefinitionEntity(org.finra.herd.model.jpa.EmrClusterDefinitionEntity)

Aggregations

Parameter (org.finra.herd.model.api.xml.Parameter)148 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)98 FieldExtension (org.activiti.bpmn.model.FieldExtension)64 HashMap (java.util.HashMap)61 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)30 Job (org.finra.herd.model.api.xml.Job)30 SystemJobRunRequest (org.finra.herd.model.api.xml.SystemJobRunRequest)20 SystemJobRunResponse (org.finra.herd.model.api.xml.SystemJobRunResponse)14 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)13 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)13 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)8 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)7 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 JobAction (org.finra.herd.model.api.xml.JobAction)6 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)6 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5