Search in sources :

Example 11 with JobDefinition

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

Example 12 with JobDefinition

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

Example 13 with JobDefinition

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

Example 14 with 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());
}
Also used : JobDefinitionEntity(org.finra.herd.model.jpa.JobDefinitionEntity) S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) JobDefinitionCreateRequest(org.finra.herd.model.api.xml.JobDefinitionCreateRequest) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) Test(org.junit.Test)

Example 15 with JobDefinition

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());
}
Also used : JobDefinitionEntity(org.finra.herd.model.jpa.JobDefinitionEntity) S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) JobDefinitionCreateRequest(org.finra.herd.model.api.xml.JobDefinitionCreateRequest) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) JobDefinitionUpdateRequest(org.finra.herd.model.api.xml.JobDefinitionUpdateRequest) Test(org.junit.Test)

Aggregations

JobDefinition (org.finra.herd.model.api.xml.JobDefinition)24 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)9 JobAction (org.finra.herd.model.api.xml.JobAction)9 JobDefinitionCreateRequest (org.finra.herd.model.api.xml.JobDefinitionCreateRequest)9 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)9 Parameter (org.finra.herd.model.api.xml.Parameter)9 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)8 Job (org.finra.herd.model.api.xml.Job)7 StorageEntity (org.finra.herd.model.jpa.StorageEntity)6 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)5 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)5 JobDefinitionUpdateRequest (org.finra.herd.model.api.xml.JobDefinitionUpdateRequest)4 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)4 InputStream (java.io.InputStream)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 JobCreateRequest (org.finra.herd.model.api.xml.JobCreateRequest)1 BusinessObjectDataNotificationEventParamsDto (org.finra.herd.model.dto.BusinessObjectDataNotificationEventParamsDto)1 StorageUnitNotificationEventParamsDto (org.finra.herd.model.dto.StorageUnitNotificationEventParamsDto)1