Search in sources :

Example 1 with JobCreateRequest

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

Example 2 with JobCreateRequest

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

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

Example 4 with JobCreateRequest

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

Example 5 with JobCreateRequest

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

Aggregations

JobCreateRequest (org.finra.herd.model.api.xml.JobCreateRequest)11 Test (org.junit.Test)7 Parameter (org.finra.herd.model.api.xml.Parameter)6 Job (org.finra.herd.model.api.xml.Job)5 JobDefinitionCreateRequest (org.finra.herd.model.api.xml.JobDefinitionCreateRequest)4 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)3 ArrayList (java.util.ArrayList)2 JdbcExecutionRequest (org.finra.herd.model.api.xml.JdbcExecutionRequest)1 JdbcExecutionResponse (org.finra.herd.model.api.xml.JdbcExecutionResponse)1 JdbcStatement (org.finra.herd.model.api.xml.JdbcStatement)1 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)1 BusinessObjectDataNotificationEventParamsDto (org.finra.herd.model.dto.BusinessObjectDataNotificationEventParamsDto)1 StorageUnitNotificationEventParamsDto (org.finra.herd.model.dto.StorageUnitNotificationEventParamsDto)1 BusinessObjectDataNotificationRegistrationEntity (org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity)1 StorageUnitNotificationRegistrationEntity (org.finra.herd.model.jpa.StorageUnitNotificationRegistrationEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1