Search in sources :

Example 56 with Parameter

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

the class GetBusinessObjectFormatTest method testGetBusinessObjectFormatMissingOptionalParameters.

/**
 * This unit test does not pass optional parameters.
 */
@Test
public void testGetBusinessObjectFormatMissingOptionalParameters() throws Exception {
    // Create and persist a business object format.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    // Retrieve the business object format without specifying the business object format value.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(GetBusinessObjectFormat.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(businessObjectFormat));
    testActivitiServiceTaskSuccess(GetBusinessObjectFormat.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 57 with Parameter

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

the class GetBusinessObjectFormatTest method testGetBusinessObjectFormat.

/**
 * This unit test passes all required and optional parameters.
 */
@Test
public void testGetBusinessObjectFormat() throws Exception {
    // Create and persist a business object format.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("businessObjectFormatVersion", INITIAL_FORMAT_VERSION.toString()));
    // Retrieve the business object format and validate the returned object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(GetBusinessObjectFormat.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(businessObjectFormat));
    testActivitiServiceTaskSuccess(GetBusinessObjectFormat.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 58 with Parameter

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

the class GetExpectedPartitionValueTest method testGetExpectedPartitionValue.

/**
 * This unit test passes all required and optional parameters.
 */
@Test
public void testGetExpectedPartitionValue() throws Exception {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Create and persist a list of expected partition values.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    // Get a sorted list of expected partition values.
    List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension(GetExpectedPartitionValue.VARIABLE_PARTITION_KEY_GROUP_NAME, "${partitionKeyGroupName}"));
    fieldExtensionList.add(buildFieldExtension(GetExpectedPartitionValue.VARIABLE_EXPECTED_PARTITION_VALUE, "${expectedPartitionValue}"));
    fieldExtensionList.add(buildFieldExtension(GetExpectedPartitionValue.VARIABLE_OFFSET, "${offset}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter(GetExpectedPartitionValue.VARIABLE_PARTITION_KEY_GROUP_NAME, PARTITION_KEY_GROUP));
    parameters.add(buildParameter(GetExpectedPartitionValue.VARIABLE_EXPECTED_PARTITION_VALUE, testSortedExpectedPartitionValues.get(TEST_EXPECTED_PARTITION_VALUE_INDEX)));
    parameters.add(buildParameter(GetExpectedPartitionValue.VARIABLE_OFFSET, TEST_OFFSET.toString()));
    // Retrieve and validate the expected partition value information.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(GetExpectedPartitionValue.VARIABLE_PARTITION_KEY_GROUP_NAME, PARTITION_KEY_GROUP);
    variableValuesToValidate.put(GetExpectedPartitionValue.VARIABLE_EXPECTED_PARTITION_VALUE, testSortedExpectedPartitionValues.get(TEST_EXPECTED_PARTITION_VALUE_INDEX + TEST_OFFSET));
    testActivitiServiceTaskSuccess(GetExpectedPartitionValue.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 59 with Parameter

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

the class InvalidateUnregisteredBusinessObjectDataTest method testInvalidateUnregisteredBusinessObjectDataSuccessXml.

/**
 * Tests a standard request that is valid XML.
 *
 * @throws Exception
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataSuccessXml() throws Exception {
    // The test request
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    // The expected response
    BusinessObjectDataInvalidateUnregisteredResponse expectedResponse = getExpectedBusinessObjectDataInvalidateUnregisteredResponse(request);
    // Setup format
    businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    // Construct Activiti parameters
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataInvalidateUnregisteredRequest", "${businessObjectDataInvalidateUnregisteredRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "xml"));
    parameters.add(buildParameter("businessObjectDataInvalidateUnregisteredRequest", xmlHelper.objectToXml(request)));
    /*
         * Assert that:
         * Status is SUCCESS
         * Error message is not set
         * Response is expected JSON
         */
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_STATUS, ActivitiRuntimeHelper.TASK_STATUS_SUCCESS);
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_ERROR_MESSAGE, VARIABLE_VALUE_IS_NULL);
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedResponse));
    testActivitiServiceTaskSuccess(InvalidateUnregisteredBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test)

Example 60 with Parameter

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

the class InvalidateUnregisteredBusinessObjectDataTest method testInvalidateUnregisteredBusinessObjectDataError.

/**
 * Test request which results in ERROR.
 *
 * @throws Exception
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataError() throws Exception {
    // The test request
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    // Construct Activiti parameters
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataInvalidateUnregisteredRequest", "${businessObjectDataInvalidateUnregisteredRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "xml"));
    parameters.add(buildParameter("businessObjectDataInvalidateUnregisteredRequest", xmlHelper.objectToXml(request)));
    /*
         * Assert that:
         * Status is ERROR
         * Error message is appropriate
         * JSON response is not set
         */
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_STATUS, ActivitiRuntimeHelper.TASK_STATUS_ERROR);
    variableValuesToValidate.put(ActivitiRuntimeHelper.VARIABLE_ERROR_MESSAGE, "Business object format with namespace \"" + request.getNamespace() + "\", business object definition name \"" + request.getBusinessObjectDefinitionName() + "\", format usage \"" + request.getBusinessObjectFormatUsage() + "\", format file type \"" + request.getBusinessObjectFormatFileType() + "\", and format version \"" + request.getBusinessObjectFormatVersion() + "\" doesn't exist.");
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_IS_NULL);
    executeWithoutLogging(ActivitiRuntimeHelper.class, () -> {
        testActivitiServiceTaskFailure(InvalidateUnregisteredBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
    });
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) 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)

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