use of org.finra.herd.model.api.xml.JobCreateRequest in project herd by FINRAOS.
the class JobRestControllerTest method testCreateJob.
@Test
public void testCreateJob() throws Exception {
// Create a job create request.
JobCreateRequest jobCreateRequest = new JobCreateRequest();
jobCreateRequest.setNamespace(JOB_NAMESPACE);
jobCreateRequest.setJobName(JOB_NAME);
// Create a job.
Job job = new Job();
job.setId(JOB_ID);
// Mock the external calls.
when(jobService.createAndStartJob(jobCreateRequest)).thenReturn(job);
// Call the method under test.
Job result = jobRestController.createJob(jobCreateRequest);
// Verify the external calls.
verify(jobService).createAndStartJob(jobCreateRequest);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(job, result);
}
use of org.finra.herd.model.api.xml.JobCreateRequest in project herd by FINRAOS.
the class JobServiceTestHelper method createJobCreateRequest.
/**
* Creates job create request using test hard coded values.
*
* @param namespaceCd the namespace code.
* @param jobName the job definition name.
* @param parameters the job parameters.
*
* @return the created job create request.
*/
public JobCreateRequest createJobCreateRequest(String namespaceCd, String jobName, List<Parameter> parameters) {
// Create a job create request.
JobCreateRequest jobCreateRequest = new JobCreateRequest();
jobCreateRequest.setNamespace(namespaceCd);
jobCreateRequest.setJobName(jobName);
jobCreateRequest.setParameters(parameters);
return jobCreateRequest;
}
use of org.finra.herd.model.api.xml.JobCreateRequest in project herd by FINRAOS.
the class JobServiceTest method testCreateJobNoParams.
@Test
public void testCreateJobNoParams() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create a job definition create request using hard coded test values.
JobDefinitionCreateRequest jobDefinitionCreateRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
jobDefinitionCreateRequest.setParameters(null);
// Create the job definition.
jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);
// Create a job create request using hard coded test values.
JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);
jobCreateRequest.setParameters(null);
// Create the job.
Job resultJob = jobService.createAndStartJob(jobCreateRequest);
// expected default parameter
List<Parameter> expectedParameters = Arrays.asList(new Parameter(HERD_WORKFLOW_ENVIRONMENT, configurationHelper.getProperty(ConfigurationValue.HERD_ENVIRONMENT)));
// Validate the results.
assertNotNull(resultJob);
assertNotNull(resultJob.getId());
assertTrue(!resultJob.getId().isEmpty());
assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace());
assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName());
assertTrue(resultJob.getParameters().size() == 1);
assertTrue(expectedParameters.containsAll(resultJob.getParameters()));
}
use of org.finra.herd.model.api.xml.JobCreateRequest in project herd by FINRAOS.
the class JobServiceTest method testCreateJob.
@Test
public void testCreateJob() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create a job definition create request using hard coded test values.
JobDefinitionCreateRequest jobDefinitionCreateRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
// Create the job definition.
jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);
// Create a job create request using hard coded test values.
JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);
// Create the job.
Job resultJob = jobService.createAndStartJob(jobCreateRequest);
// Validate the results.
assertNotNull(resultJob);
assertNotNull(resultJob.getId());
assertTrue(!resultJob.getId().isEmpty());
assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace());
assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName());
assertEquals(jobDefinitionCreateRequest.getParameters().size() + jobCreateRequest.getParameters().size() + 1, resultJob.getParameters().size());
List<String> expectedParameters = new ArrayList<>();
expectedParameters.addAll(parametersToStringList(jobDefinitionCreateRequest.getParameters()));
expectedParameters.addAll(parametersToStringList(jobCreateRequest.getParameters()));
expectedParameters.addAll(parametersToStringList(Arrays.asList(new Parameter(HERD_WORKFLOW_ENVIRONMENT, configurationHelper.getProperty(ConfigurationValue.HERD_ENVIRONMENT)))));
List<String> resultParameters = parametersToStringList(resultJob.getParameters());
assertTrue(expectedParameters.containsAll(resultParameters));
assertTrue(resultParameters.containsAll(expectedParameters));
}
use of org.finra.herd.model.api.xml.JobCreateRequest in project herd by FINRAOS.
the class JobServiceTest method testCreateJobWithS3PropertiesJobDefinitionWrongDatafixSafety.
/**
* Tests an edge case where the job definition was persisted with some S3 properties location, but due to some datafix, the S3 properties location's object
* key was removed, but not the bucket name. The service should still work, it would simply ignore the definition's S3 properties location.
*
* @throws Exception
*/
@Test
public void testCreateJobWithS3PropertiesJobDefinitionWrongDatafixSafety() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create a job definition create request using hard coded test values.
JobDefinitionCreateRequest jobDefinitionCreateRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
jobDefinitionCreateRequest.setS3PropertiesLocation(getS3PropertiesLocation("testBucketName", "testObjectKey", new Parameter("testName", "testValue")));
jobDefinitionCreateRequest.setParameters(null);
// Create the job definition.
JobDefinition jobDefinition = jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);
Integer jobDefinitionId = jobDefinition.getId();
JobDefinitionEntity jobDefinitionEntity = herdDao.findById(JobDefinitionEntity.class, jobDefinitionId);
jobDefinitionEntity.setS3ObjectKey(null);
// Create a job create request using hard coded test values.
JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME);
jobCreateRequest.setParameters(null);
// Create the job.
Job resultJob = jobService.createAndStartJob(jobCreateRequest);
Assert.assertNotNull("resultJob parameters", resultJob.getParameters());
}
Aggregations