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;
}
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);
}
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());
}
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);
}
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());
}
Aggregations