use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JdbcServiceTest method testExecuteJdbcParamValidationS3PropertiesLocationBucketNameBlank.
/**
* When S3 properties location is specified, bucket name must not be a blank string.
*/
@Test
public void testExecuteJdbcParamValidationS3PropertiesLocationBucketNameBlank() {
JdbcExecutionRequest jdbcExecutionRequest = jdbcServiceTestHelper.createDefaultUpdateJdbcExecutionRequest();
jdbcExecutionRequest.setS3PropertiesLocation(new S3PropertiesLocation(BLANK_TEXT, "test_key"));
try {
jdbcService.executeJdbc(jdbcExecutionRequest);
Assert.fail("expected an IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
Assert.assertEquals("thrown exception type", IllegalArgumentException.class, e.getClass());
Assert.assertEquals("thrown exception message", "S3 properties location bucket name is required", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JobRestControllerTest method testSignalJob.
@Test
public void testSignalJob() throws Exception {
// Create a job signal request.
JobSignalRequest jobSignalRequest = new JobSignalRequest(JOB_ID, JOB_RECEIVE_TASK_ID, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1)), new S3PropertiesLocation(S3_BUCKET_NAME, S3_KEY));
// Create a job.
Job job = new Job();
job.setId(JOB_ID);
// Mock the external calls.
when(jobService.signalJob(jobSignalRequest)).thenReturn(job);
// Call the method under test.
Job result = jobRestController.signalJob(jobSignalRequest);
// Verify the external calls.
verify(jobService).signalJob(jobSignalRequest);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(job, result);
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class S3PropertiesLocationHelperTest method testValidateNoErrorsAndTrimmed.
/**
* validate() throws no errors when {@link S3PropertiesLocation} is given with both bucket name and key as a non-blank string.
* The given object's bucket name and key should be trimmed as a side effect.
*/
@Test
public void testValidateNoErrorsAndTrimmed() {
S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation();
String expectedBucketName = s3PropertiesLocation.getBucketName();
String expectedKey = s3PropertiesLocation.getKey();
s3PropertiesLocation.setBucketName(BLANK_TEXT + s3PropertiesLocation.getBucketName() + BLANK_TEXT);
s3PropertiesLocation.setKey(BLANK_TEXT + s3PropertiesLocation.getKey() + BLANK_TEXT);
try {
s3PropertiesLocationHelper.validate(s3PropertiesLocation);
Assert.assertEquals("s3PropertiesLocation bucketName", expectedBucketName, s3PropertiesLocation.getBucketName());
Assert.assertEquals("s3PropertiesLocation key", expectedKey, s3PropertiesLocation.getKey());
} catch (Exception e) {
Assert.fail("unexpected exception was thrown. " + e);
}
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JobServiceImpl method getParameters.
/**
* Gets the parameters from the given {@link JobDefinitionEntity} and {@link JobCreateRequest} and their respective S3 locations provided. If there are any
* parameter conflicts, this method will automatically merge them by a predefined precedence, from least to greatest: <ol> <li>Job Definition S3
* location</li> <li>Job Definition parameters</li> <li>Job Create Request S3 location</li> <li>Job Create Request parameters</li> </ol>
*
* @param jobDefinitionEntity {@link JobDefinitionEntity}
* @param jobCreateRequest {@link JobCreateRequest}
*
* @return merged parameters
*/
private Map<String, Object> getParameters(JobDefinitionEntity jobDefinitionEntity, JobCreateRequest jobCreateRequest) {
Map<String, Object> mergedParameters = new HashMap<>();
// Get parameters from job definition S3 location
putParametersFromS3(jobDefinitionEntity.getS3BucketName(), jobDefinitionEntity.getS3ObjectKey(), mergedParameters);
// Get parameters from job definition parameters
for (JobDefinitionParameterEntity definitionParam : jobDefinitionEntity.getParameters()) {
mergedParameters.put(definitionParam.getName(), definitionParam.getValue());
}
// Get parameters from job create request S3 location
S3PropertiesLocation s3PropertiesLocation = jobCreateRequest.getS3PropertiesLocation();
if (s3PropertiesLocation != null) {
putParametersFromS3(s3PropertiesLocation.getBucketName(), s3PropertiesLocation.getKey(), mergedParameters);
}
// Get parameters from job create request parameters
mergedParameters.putAll(toMap(jobCreateRequest.getParameters()));
return mergedParameters;
}
use of org.finra.herd.model.api.xml.S3PropertiesLocation in project herd by FINRAOS.
the class JobServiceImpl method getParameters.
/**
* Gets the parameters from the given {@link JobSignalRequest} and the S3 location provided.
*
* @param jobSignalRequest {@link JobSignalRequest}
*
* @return parameters
*/
private Map<String, Object> getParameters(JobSignalRequest jobSignalRequest) {
Map<String, Object> signalParameters = new HashMap<>();
// Get parameters from S3
S3PropertiesLocation s3PropertiesLocation = jobSignalRequest.getS3PropertiesLocation();
if (s3PropertiesLocation != null) {
putParametersFromS3(s3PropertiesLocation.getBucketName(), s3PropertiesLocation.getKey(), signalParameters);
}
// Get parameters from request
signalParameters.putAll(toMap(jobSignalRequest.getParameters()));
return signalParameters;
}
Aggregations