Search in sources :

Example 71 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class JobDefinitionServiceTest method createUpdateRequest.

/**
 * Create an update request with a varied set of data that is based on the same data used in the create request.
 *
 * @param createRequest the create request.
 *
 * @return the update request.
 */
private JobDefinitionUpdateRequest createUpdateRequest(JobDefinitionCreateRequest createRequest) {
    // Create an update request that modifies all data from the create request.
    JobDefinitionUpdateRequest updateRequest = new JobDefinitionUpdateRequest();
    updateRequest.setDescription(createRequest.getDescription() + "2");
    updateRequest.setActivitiJobXml(createRequest.getActivitiJobXml().replace("Unit Test", "Unit Test 2"));
    List<Parameter> parameters = new ArrayList<>();
    updateRequest.setParameters(parameters);
    // Delete the first parameter, update the second parameter, and add a new third parameter.
    Parameter parameter = new Parameter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2 + "2");
    parameters.add(parameter);
    parameter = new Parameter(ATTRIBUTE_NAME_3_MIXED_CASE, ATTRIBUTE_VALUE_3);
    parameters.add(parameter);
    return updateRequest;
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) JobDefinitionUpdateRequest(org.finra.herd.model.api.xml.JobDefinitionUpdateRequest)

Example 72 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class JobDefinitionServiceTestHelper method createJobDefinitionCreateRequestFromActivitiXml.

/**
 * Creates a new job definition create request based on fixed parameters and a specified activiti XML.
 *
 * @param activitiXml the Activiti XML.
 */
public JobDefinitionCreateRequest createJobDefinitionCreateRequestFromActivitiXml(String activitiXml) {
    // Create a test list of parameters.
    List<Parameter> parameters = new ArrayList<>();
    Parameter parameter = new Parameter(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE);
    parameters.add(parameter);
    return createJobDefinitionCreateRequest(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD, AbstractServiceTest.TEST_ACTIVITI_JOB_NAME, AbstractServiceTest.JOB_DESCRIPTION, activitiXml, parameters);
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter)

Example 73 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class JobServiceTest method assertParameterEquals.

/**
 * Asserts that the given expected parameter exists and value matches from the given collection of parameters.
 *
 * @param expectedParameter the expected parameter
 * @param actualParameters the actual parameter
 */
private void assertParameterEquals(Parameter expectedParameter, List<Parameter> actualParameters) {
    String name = expectedParameter.getName();
    Parameter actualParameter = getParameter(name, actualParameters);
    Assert.assertNotNull("parameter ['" + name + "'] not found", actualParameter);
    Assert.assertEquals("parameter ['" + name + "'] value", actualParameter.getValue(), expectedParameter.getValue());
}
Also used : Parameter(org.finra.herd.model.api.xml.Parameter)

Example 74 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class JobServiceTest method testCreateJobWithS3PropertiesPrecedenceDefinitionParamsOverridesDefinitionS3.

/**
 * Creates a job where the definition has S3 properties and parameters and request has no parameters. The job definition parameters should take precedence
 * if there are name clashes.
 *
 * @throws Exception
 */
@Test
public void testCreateJobWithS3PropertiesPrecedenceDefinitionParamsOverridesDefinitionS3() throws Exception {
    Parameter jobDefinitionS3Parameter = new Parameter("testName", "testValue1");
    Parameter jobDefinitionRequestParameter = new Parameter("testName", "expectedValue");
    String s3BucketName = "s3BucketName";
    S3PropertiesLocation jobDefinitionS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobDefinitionObjectKey", jobDefinitionS3Parameter);
    Job resultJob = createJobWithParameters(jobDefinitionS3PropertiesLocation, Arrays.asList(jobDefinitionRequestParameter), null, null);
    List<Parameter> actualParameters = resultJob.getParameters();
    assertParameterEquals(jobDefinitionRequestParameter, actualParameters);
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) Parameter(org.finra.herd.model.api.xml.Parameter) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test)

Example 75 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class JobServiceTest method testSignalJobWithS3PropertiesPrecedenceRequestParamsOverridesS3.

/**
 * Signals job with both S3 properties and request parameters set. If there are name clashes, the request parameter should take precedence.
 *
 * @throws Exception
 */
@Test
public void testSignalJobWithS3PropertiesPrecedenceRequestParamsOverridesS3() throws Exception {
    jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_TEST_RECEIVE_TASK_WITH_CLASSPATH);
    Parameter s3Parameter = new Parameter("testName", "testValue");
    Parameter requestParameter = new Parameter("testName", "expectedValue");
    S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation("s3BucketName", "s3ObjectKey", s3Parameter);
    // 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);
    jobSignalRequest.setParameters(Arrays.asList(requestParameter));
    Job signalJob = jobService.signalJob(jobSignalRequest);
    assertParameterEquals(requestParameter, signalJob.getParameters());
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) Parameter(org.finra.herd.model.api.xml.Parameter) JobSignalRequest(org.finra.herd.model.api.xml.JobSignalRequest) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test)

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