use of org.finra.herd.model.api.xml.Parameter 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.Parameter in project herd by FINRAOS.
the class ParameterHelper method validateParameters.
/**
* Validates that parameter names are there and that there are no duplicate parameter names in case insensitive manner. This method also trims parameter
* names.
*
* @param parameters the list of parameters to be validated
*/
public void validateParameters(List<Parameter> parameters) {
if (!CollectionUtils.isEmpty(parameters)) {
Set<String> parameterNameValidationSet = new HashSet<>();
for (Parameter parameter : parameters) {
// Validate and trim the parameter name.
Assert.hasText(parameter.getName(), "A parameter name must be specified.");
parameter.setName(parameter.getName().trim());
// Ensure the parameter name isn't a duplicate by using a set with a "lowercase" name as the key for case insensitivity.
String lowercaseParameterName = parameter.getName().toLowerCase();
Assert.isTrue(!parameterNameValidationSet.contains(lowercaseParameterName), "Duplicate parameter name found: " + parameter.getName());
parameterNameValidationSet.add(lowercaseParameterName);
}
}
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class JobDefinitionHelperTest method testMaskPassword.
@Test
public void testMaskPassword() {
Parameter parameter = new Parameter(null, null);
jobDefinitionHelper.maskPassword(parameter);
// name is still null
assertNull(parameter.getName());
parameter = new Parameter("name", "val");
// no mask is expected
jobDefinitionHelper.maskPassword(parameter);
assertEquals(parameter.getValue(), "val");
parameter = new Parameter("passWord", "val");
jobDefinitionHelper.maskPassword(parameter);
assertEquals(parameter.getValue(), "****");
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class GenerateBusinessObjectDataDdlCollectionTest method testGenerateBusinessObjectDataDdlCollectionJson.
@Test
public void testGenerateBusinessObjectDataDdlCollectionJson() throws Exception {
// Prepare database entities required for testing.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting(AbstractServiceTest.PARTITION_VALUE);
// Prepare the request.
BusinessObjectDataDdlCollectionRequest request = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlCollectionRequest();
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataDdlCollectionRequest", "${businessObjectDataDdlCollectionRequest}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("contentType", "json"));
parameters.add(buildParameter("businessObjectDataDdlCollectionRequest", jsonHelper.objectToJson(request)));
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GenerateBusinessObjectDataDdlCollection.VARIABLE_DDL_COLLECTION, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataDdlCollectionResponse().getDdlCollection());
executeWithoutLogging(LogVariables.class, () -> {
testActivitiServiceTaskSuccess(GenerateBusinessObjectDataDdlCollection.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
});
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class GenerateBusinessObjectDataDdlTest method testGenerateBusinessObjectDataDdlJson.
@Test
public void testGenerateBusinessObjectDataDdlJson() throws Exception {
// Prepare test data.
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataDdlTesting();
BusinessObjectDataDdlRequest businessObjectDataDdlRequest = businessObjectDataServiceTestHelper.getTestBusinessObjectDataDdlRequest(UNSORTED_PARTITION_VALUES, CUSTOM_DDL_NAME);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataDdlRequest", "${businessObjectDataDdlRequest}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("contentType", "json"));
parameters.add(buildParameter("businessObjectDataDdlRequest", jsonHelper.objectToJson(businessObjectDataDdlRequest)));
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GenerateBusinessObjectDataDdl.VARIABLE_DDL, VARIABLE_VALUE_NOT_NULL);
executeWithoutLogging(LogVariables.class, () -> {
testActivitiServiceTaskSuccess(GenerateBusinessObjectDataDdl.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
});
}
Aggregations