Search in sources :

Example 16 with S3PropertiesLocation

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

the class JobDefinitionServiceTest method testCreateJobDefinitionWithS3PropertiesLocationValidateObjectKeyRequired.

/**
 * Asserts that if {@link S3PropertiesLocation} is given, key is required.
 *
 * @throws Exception
 */
@Test
public void testCreateJobDefinitionWithS3PropertiesLocationValidateObjectKeyRequired() throws Exception {
    S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation();
    s3PropertiesLocation.setKey(null);
    testCreateJobDefinitionWithS3PropertiesLocationValidate(s3PropertiesLocation, IllegalArgumentException.class, "S3 properties location object key must be specified.");
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) Test(org.junit.Test)

Example 17 with S3PropertiesLocation

use of org.finra.herd.model.api.xml.S3PropertiesLocation 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 18 with S3PropertiesLocation

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

the class JobDefinitionServiceTest method testCreateJobDefinitionWithS3PropertiesLocationValidateBucketNameRequired.

/**
 * Asserts that if {@link S3PropertiesLocation} is given, bucket name is required.
 *
 * @throws Exception
 */
@Test
public void testCreateJobDefinitionWithS3PropertiesLocationValidateBucketNameRequired() throws Exception {
    S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation();
    s3PropertiesLocation.setBucketName(null);
    testCreateJobDefinitionWithS3PropertiesLocationValidate(s3PropertiesLocation, IllegalArgumentException.class, "S3 properties location bucket name must be specified.");
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) Test(org.junit.Test)

Example 19 with S3PropertiesLocation

use of org.finra.herd.model.api.xml.S3PropertiesLocation 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 20 with S3PropertiesLocation

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

the class JobServiceTest method testCreateJobWithS3PropertiesPrecedenceDefinitionParamsOverridesDefinitionS3.

/**
 * Creates a job where the definition has S3 properties and parameters and request has no parameters. The job definition parameters should take precedence
 * if there are name clashes.
 *
 * @throws Exception
 */
@Test
public void testCreateJobWithS3PropertiesPrecedenceDefinitionParamsOverridesDefinitionS3() throws Exception {
    Parameter jobDefinitionS3Parameter = new Parameter("testName", "testValue1");
    Parameter jobDefinitionRequestParameter = new Parameter("testName", "expectedValue");
    String s3BucketName = "s3BucketName";
    S3PropertiesLocation jobDefinitionS3PropertiesLocation = getS3PropertiesLocation(s3BucketName, "jobDefinitionObjectKey", jobDefinitionS3Parameter);
    Job resultJob = createJobWithParameters(jobDefinitionS3PropertiesLocation, Arrays.asList(jobDefinitionRequestParameter), null, null);
    List<Parameter> actualParameters = resultJob.getParameters();
    assertParameterEquals(jobDefinitionRequestParameter, actualParameters);
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) Parameter(org.finra.herd.model.api.xml.Parameter) Job(org.finra.herd.model.api.xml.Job) Test(org.junit.Test)

Aggregations

S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)33 Test (org.junit.Test)26 Parameter (org.finra.herd.model.api.xml.Parameter)13 Job (org.finra.herd.model.api.xml.Job)7 JdbcExecutionRequest (org.finra.herd.model.api.xml.JdbcExecutionRequest)6 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)5 AccessDeniedException (org.springframework.security.access.AccessDeniedException)5 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)4 JdbcExecutionResponse (org.finra.herd.model.api.xml.JdbcExecutionResponse)3 JobDefinitionCreateRequest (org.finra.herd.model.api.xml.JobDefinitionCreateRequest)3 JobSignalRequest (org.finra.herd.model.api.xml.JobSignalRequest)3 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)3 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)3 HashMap (java.util.HashMap)2 JdbcStatement (org.finra.herd.model.api.xml.JdbcStatement)2 JobDefinitionUpdateRequest (org.finra.herd.model.api.xml.JobDefinitionUpdateRequest)2 JobDefinitionParameterEntity (org.finra.herd.model.jpa.JobDefinitionParameterEntity)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 DataSource (javax.sql.DataSource)1