Search in sources :

Example 86 with Parameter

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

Example 87 with Parameter

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

Example 88 with Parameter

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(), "****");
}
Also used : Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 89 with Parameter

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);
    });
}
Also used : BusinessObjectDataDdlCollectionRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlCollectionRequest) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 90 with Parameter

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);
    });
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) BusinessObjectDataDdlRequest(org.finra.herd.model.api.xml.BusinessObjectDataDdlRequest) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Aggregations

Parameter (org.finra.herd.model.api.xml.Parameter)148 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)98 FieldExtension (org.activiti.bpmn.model.FieldExtension)64 HashMap (java.util.HashMap)61 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)30 Job (org.finra.herd.model.api.xml.Job)30 SystemJobRunRequest (org.finra.herd.model.api.xml.SystemJobRunRequest)20 SystemJobRunResponse (org.finra.herd.model.api.xml.SystemJobRunResponse)14 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)13 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)13 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)8 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)7 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 JobAction (org.finra.herd.model.api.xml.JobAction)6 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)6 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5