Search in sources :

Example 6 with JobDefinitionUpdateRequest

use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest 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)

Example 7 with JobDefinitionUpdateRequest

use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest in project herd by FINRAOS.

the class JobDefinitionServiceTest method testUpdateJobDefinitionNamespaceNoExist.

@Test(expected = ObjectNotFoundException.class)
public void testUpdateJobDefinitionNamespaceNoExist() throws Exception {
    // Create an update request.
    JobDefinitionUpdateRequest updateRequest = createUpdateRequest(jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest());
    // Update the process Id to match an invalid namespace and invalid job name to pass validation.
    updateRequest.setActivitiJobXml(updateRequest.getActivitiJobXml().replace(TEST_ACTIVITI_NAMESPACE_CD + "." + TEST_ACTIVITI_JOB_NAME, INVALID_NAME + "." + INVALID_NAME));
    // Try to update a job definition that has a namespace that doesn't exist.
    jobDefinitionService.updateJobDefinition(INVALID_NAME, INVALID_NAME, updateRequest, false);
}
Also used : JobDefinitionUpdateRequest(org.finra.herd.model.api.xml.JobDefinitionUpdateRequest) Test(org.junit.Test)

Example 8 with JobDefinitionUpdateRequest

use of org.finra.herd.model.api.xml.JobDefinitionUpdateRequest in project herd by FINRAOS.

the class JobDefinitionServiceTest method testUpdateJobDefinition.

@Test
public void testUpdateJobDefinition() throws Exception {
    // Create job definition create request using hard coded test values.
    JobDefinitionCreateRequest createRequest = jobDefinitionServiceTestHelper.createJobDefinitionCreateRequest();
    // Set 2 distinct parameters.
    List<Parameter> parameters = new ArrayList<>();
    createRequest.setParameters(parameters);
    Parameter parameter = new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
    parameters.add(parameter);
    parameter = new Parameter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2);
    parameters.add(parameter);
    // Create the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);
    // 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);
    // Validate the updated job definition.
    assertEquals(new JobDefinition(jobDefinition.getId(), jobDefinition.getNamespace(), jobDefinition.getJobName(), updateRequest.getDescription(), updateRequest.getActivitiJobXml(), updateRequest.getParameters(), jobDefinition.getS3PropertiesLocation(), HerdDaoSecurityHelper.SYSTEM_USER), updatedJobDefinition);
}
Also used : JobDefinitionCreateRequest(org.finra.herd.model.api.xml.JobDefinitionCreateRequest) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) JobDefinitionUpdateRequest(org.finra.herd.model.api.xml.JobDefinitionUpdateRequest) Test(org.junit.Test)

Aggregations

JobDefinitionUpdateRequest (org.finra.herd.model.api.xml.JobDefinitionUpdateRequest)8 Test (org.junit.Test)7 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)4 JobDefinitionCreateRequest (org.finra.herd.model.api.xml.JobDefinitionCreateRequest)4 ArrayList (java.util.ArrayList)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)2 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 EndEvent (org.activiti.bpmn.model.EndEvent)1 Process (org.activiti.bpmn.model.Process)1 ScriptTask (org.activiti.bpmn.model.ScriptTask)1 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)1 StartEvent (org.activiti.bpmn.model.StartEvent)1