use of org.finra.herd.model.api.xml.JobDefinition 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());
}
use of org.finra.herd.model.api.xml.JobDefinition in project herd by FINRAOS.
the class JobDefinitionRestControllerTest method testGetJobDefinition.
@Test
public void testGetJobDefinition() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
JobDefinition jobDefinition = getJobDefinition(NAMESPACE, JOB_NAME);
when(jobDefinitionService.getJobDefinition(namespace, jobName)).thenReturn(jobDefinition);
JobDefinition resultJobDefinition = jobDefinitionRestController.getJobDefinition(namespace, jobName);
// Verify the external calls.
verify(jobDefinitionService).getJobDefinition(namespace, jobName);
verifyNoMoreInteractions(jobDefinitionService);
// Validate the returned object.
assertEquals(jobDefinition, resultJobDefinition);
}
use of org.finra.herd.model.api.xml.JobDefinition in project herd by FINRAOS.
the class JobDefinitionServiceTest method testGetJobDefinition.
@Test
public void testGetJobDefinition() throws Exception {
// Create a new job definition.
JobDefinition jobDefinition = createJobDefinition();
// Retrieve the job definition.
jobDefinition = jobDefinitionService.getJobDefinition(jobDefinition.getNamespace(), jobDefinition.getJobName());
// Validate that the retrieved job definition matches what we created.
validateJobDefinition(jobDefinition);
}
use of org.finra.herd.model.api.xml.JobDefinition in project herd by FINRAOS.
the class JobDefinitionServiceTest method testCreateJobDefinitionWithS3PropertiesLocationPersistsEntity.
/**
* Asserts that when a job definition is created using {@link S3PropertiesLocation}, the S3 location information is persisted.
*
* @throws Exception
*/
@Test
public void testCreateJobDefinitionWithS3PropertiesLocationPersistsEntity() throws Exception {
S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation();
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
JobDefinitionCreateRequest request = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
request.setS3PropertiesLocation(s3PropertiesLocation);
JobDefinition jobDefinition = jobDefinitionService.createJobDefinition(request, false);
Assert.assertEquals("jobDefinition s3PropertiesLocation", request.getS3PropertiesLocation(), jobDefinition.getS3PropertiesLocation());
JobDefinitionEntity jobDefinitionEntity = herdDao.findById(JobDefinitionEntity.class, jobDefinition.getId());
Assert.assertNotNull("jobDefinitionEntity is null", jobDefinitionEntity);
Assert.assertEquals("jobDefinitionEntity s3BucketName", s3PropertiesLocation.getBucketName(), jobDefinitionEntity.getS3BucketName());
Assert.assertEquals("jobDefinitionEntity s3ObjectKey", s3PropertiesLocation.getKey(), jobDefinitionEntity.getS3ObjectKey());
}
use of org.finra.herd.model.api.xml.JobDefinition in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinitionWithS3PropertiesClear.
@Test
public void testUpdateJobDefinitionWithS3PropertiesClear() throws Exception {
S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation();
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
// Create job definition create request using hard coded test values.
JobDefinitionCreateRequest createRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
createRequest.setS3PropertiesLocation(s3PropertiesLocation);
// Create the job definition in the database.
JobDefinition jobDefinition = jobDefinitionService.createJobDefinition(createRequest, false);
// Create an update request with a varied set of data that is based on the same data used in the create request.
JobDefinitionUpdateRequest updateRequest = createUpdateRequest(createRequest);
// Update the job definition in the database.
JobDefinition updatedJobDefinition = jobDefinitionService.updateJobDefinition(createRequest.getNamespace(), createRequest.getJobName(), updateRequest, false);
JobDefinitionEntity updatedJobDefinitionEntity = herdDao.findById(JobDefinitionEntity.class, updatedJobDefinition.getId());
// Validate the updated job definition.
assertEquals(new JobDefinition(jobDefinition.getId(), jobDefinition.getNamespace(), jobDefinition.getJobName(), updateRequest.getDescription(), updateRequest.getActivitiJobXml(), updateRequest.getParameters(), null, HerdDaoSecurityHelper.SYSTEM_USER), updatedJobDefinition);
// Validate the updated job definition entity.
Assert.assertNull("updatedJobDefinitionEntity s3BucketName", updatedJobDefinitionEntity.getS3BucketName());
Assert.assertNull("updatedJobDefinitionEntity s3ObjectKey", updatedJobDefinitionEntity.getS3ObjectKey());
}
Aggregations