Search in sources :

Example 16 with JobDefinition

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

the class JobDefinitionServiceTestHelper method createJobDefinition.

/**
 * Creates a job definition based on the specified Activiti XML classpath resource location.
 *
 * @param activitiXmlClasspathResourceName the Activiti XML classpath resource location.
 *
 * @return the job definition.
 * @throws Exception if any errors were encountered.
 */
public JobDefinition createJobDefinition(String activitiXmlClasspathResourceName) throws Exception {
    // Create the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(AbstractServiceTest.TEST_ACTIVITI_NAMESPACE_CD);
    // Create and persist a valid job definition.
    JobDefinitionCreateRequest jobDefinitionCreateRequest = createJobDefinitionCreateRequest(activitiXmlClasspathResourceName);
    JobDefinition jobDefinition = jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);
    // Validate the returned object against the input.
    assertEquals(new JobDefinition(jobDefinition.getId(), jobDefinitionCreateRequest.getNamespace(), jobDefinitionCreateRequest.getJobName(), jobDefinitionCreateRequest.getDescription(), jobDefinitionCreateRequest.getActivitiJobXml(), jobDefinitionCreateRequest.getParameters(), jobDefinitionCreateRequest.getS3PropertiesLocation(), HerdDaoSecurityHelper.SYSTEM_USER), jobDefinition);
    return jobDefinition;
}
Also used : JobDefinitionCreateRequest(org.finra.herd.model.api.xml.JobDefinitionCreateRequest) JobDefinition(org.finra.herd.model.api.xml.JobDefinition)

Example 17 with JobDefinition

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

the class NotificationEventServiceTest method testProcessBusinessObjectDataRegistrationNotificationEventSyncMultipleNotifications.

@Test
public void testProcessBusinessObjectDataRegistrationNotificationEventSyncMultipleNotifications() throws Exception {
    // Create job definition
    JobDefinition jobDefinition = jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_LOG_VARIABLES_NO_REGEX_WITH_CLASSPATH);
    List<JobAction> jobActions = new ArrayList<>();
    jobActions.add(new JobAction(jobDefinition.getNamespace(), jobDefinition.getJobName(), CORRELATION_DATA));
    // Create business object data with storage units.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3);
    storageUnitDaoTestHelper.createStorageUnitEntity(storageEntity, businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    // Create and persist a business object data notification registration entity.
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, null, jobActions, NotificationRegistrationStatusEntity.ENABLED);
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME_2), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, null, jobActions, NotificationRegistrationStatusEntity.ENABLED);
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Trigger the notification
    List<Object> notificationActions = notificationEventService.processBusinessObjectDataNotificationEventSync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN, businessObjectDataKey, BDATA_STATUS, null);
    assertTrue(notificationActions.size() == 2);
    for (Object notificationAction : notificationActions) {
        Job job = (Job) notificationAction;
        assertNotNull(job);
        assertEquals(TEST_ACTIVITI_NAMESPACE_CD, job.getNamespace());
        assertEquals(TEST_ACTIVITI_JOB_NAME, job.getJobName());
        Parameter parameter = null;
        for (Parameter param : job.getParameters()) {
            if (param.getName().equals("notification_correlationData")) {
                parameter = param;
                break;
            }
        }
        assertNotNull(parameter);
        assertEquals(CORRELATION_DATA, parameter.getValue());
    }
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Job(org.finra.herd.model.api.xml.Job) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 18 with JobDefinition

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

the class NotificationEventServiceTest method testProcessBusinessObjectDataRegistrationNotificationEventSyncAssertNoopWhenAllDisabled.

@Test
public void testProcessBusinessObjectDataRegistrationNotificationEventSyncAssertNoopWhenAllDisabled() throws Exception {
    // Create job definition
    JobDefinition jobDefinition = jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_LOG_VARIABLES_NO_REGEX_WITH_CLASSPATH);
    List<JobAction> jobActions1 = Arrays.asList(new JobAction(jobDefinition.getNamespace(), jobDefinition.getJobName(), CORRELATION_DATA));
    List<JobAction> jobActions2 = Arrays.asList(new JobAction(jobDefinition.getNamespace(), jobDefinition.getJobName(), CORRELATION_DATA_2));
    // Create a business object format with a schema.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, FIRST_PARTITION_COLUMN_NAME, NO_PARTITION_KEY_GROUP, NO_ATTRIBUTES, SCHEMA_DELIMITER_PIPE, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, SCHEMA_NULL_VALUE_BACKSLASH_N, schemaColumnDaoTestHelper.getTestSchemaColumns(), schemaColumnDaoTestHelper.getTestPartitionColumns());
    // Create business object data with storage units.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3);
    storageUnitDaoTestHelper.createStorageUnitEntity(storageEntity, businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    // Create and persist a business object data notification registration entity that is enabled.
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, null, jobActions1, NotificationRegistrationStatusEntity.DISABLED);
    // Create and persist a business object data notification registration entity that is disabled.
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME_2), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME_2, BDATA_STATUS, null, jobActions2, NotificationRegistrationStatusEntity.DISABLED);
    // Trigger the notification
    List<Object> notificationActions = notificationEventService.processBusinessObjectDataNotificationEventSync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN, new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS, null);
    assertEquals(0, notificationActions.size());
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 19 with JobDefinition

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

the class NotificationEventServiceTest method testProcessBusinessObjectDataRegistrationNotificationEventSyncMissingOptional.

@Test
public void testProcessBusinessObjectDataRegistrationNotificationEventSyncMissingOptional() throws Exception {
    // Create job definition
    JobDefinition jobDefinition = jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_LOG_VARIABLES_NO_REGEX_WITH_CLASSPATH);
    List<JobAction> jobActions = new ArrayList<>();
    jobActions.add(new JobAction(jobDefinition.getNamespace(), jobDefinition.getJobName(), CORRELATION_DATA));
    // Create business object data without storage units.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    // Create and persist a business object data notification registration entity.
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), BDEF_NAMESPACE, BDEF_NAME, null, null, null, null, null, null, jobActions, NotificationRegistrationStatusEntity.ENABLED);
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Trigger the notification
    List<Object> notificationActions = notificationEventService.processBusinessObjectDataNotificationEventSync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN, businessObjectDataKey, BDATA_STATUS, null);
    Job job = (Job) notificationActions.get(0);
    assertNotNull(job);
    assertEquals(TEST_ACTIVITI_NAMESPACE_CD, job.getNamespace());
    assertEquals(TEST_ACTIVITI_JOB_NAME, job.getJobName());
    Parameter parameter = null;
    for (Parameter param : job.getParameters()) {
        if (param.getName().equals("notification_correlationData")) {
            parameter = param;
            break;
        }
    }
    assertNotNull(parameter);
    assertEquals(CORRELATION_DATA, parameter.getValue());
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Job(org.finra.herd.model.api.xml.Job) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 20 with JobDefinition

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

the class NotificationEventServiceTest method runProcessBusinessObjectDataStatusChangeNotificationEventSyncTest.

private void runProcessBusinessObjectDataStatusChangeNotificationEventSyncTest() throws Exception {
    // Create a job definition.
    JobDefinition jobDefinition = jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_LOG_VARIABLES_NO_REGEX_WITH_CLASSPATH);
    List<JobAction> jobActions = new ArrayList<>();
    jobActions.add(new JobAction(jobDefinition.getNamespace(), jobDefinition.getJobName(), CORRELATION_DATA));
    // Create a business object format with a schema.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, FIRST_PARTITION_COLUMN_NAME, NO_PARTITION_KEY_GROUP, NO_ATTRIBUTES, SCHEMA_DELIMITER_PIPE, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, SCHEMA_NULL_VALUE_BACKSLASH_N, schemaColumnDaoTestHelper.getTestSchemaColumns(), schemaColumnDaoTestHelper.getTestPartitionColumns());
    // Create business object data with a storage unit.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.UPLOADING);
    StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3);
    storageUnitDaoTestHelper.createStorageUnitEntity(storageEntity, businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
    // Create and persist a business object data notification registration entity.
    notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.UPLOADING, jobActions, NotificationRegistrationStatusEntity.ENABLED);
    // Trigger the notification.
    List<Object> notificationActions = notificationEventService.processBusinessObjectDataNotificationEventSync(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG, new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.UPLOADING);
    // Validate the result job.
    Job job = (Job) notificationActions.get(0);
    assertEquals(new Job(job.getId(), null, TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, null, null, null, null, Arrays.asList(new Parameter("notification_businessObjectDefinitionName", BDEF_NAME), new Parameter("notification_partitionValues", PARTITION_VALUE + "|" + StringUtils.join(SUBPARTITION_VALUES, "|")), new Parameter("notification_namespace", NAMESPACE), new Parameter("notification_businessObjectData", jsonHelper.objectToJson(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity))), new Parameter("notification_businessObjectFormatUsage", FORMAT_USAGE_CODE), new Parameter(HERD_WORKFLOW_ENVIRONMENT, configurationHelper.getProperty(ConfigurationValue.HERD_ENVIRONMENT)), new Parameter("notification_businessObjectDefinitionNamespace", BDEF_NAMESPACE), new Parameter("notification_newBusinessObjectDataStatus", BusinessObjectDataStatusEntity.VALID), new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1), new Parameter("notification_businessObjectDataVersion", DATA_VERSION.toString()), new Parameter("notification_name", NOTIFICATION_NAME), new Parameter("notification_oldBusinessObjectDataStatus", BusinessObjectDataStatusEntity.UPLOADING), new Parameter("notification_partitionColumnNames", "PRTN_CLMN001|PRTN_CLMN002|PRTN_CLMN003|PRTN_CLMN004|PRTN_CLMN005"), new Parameter("notification_businessObjectDataEventType", NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name()), new Parameter("notification_businessObjectFormatVersion", FORMAT_VERSION.toString()), new Parameter("notification_businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE), new Parameter("notification_correlationData", CORRELATION_DATA)), null, null, null), job);
}
Also used : ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) JobAction(org.finra.herd.model.api.xml.JobAction) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Job(org.finra.herd.model.api.xml.Job) JobDefinition(org.finra.herd.model.api.xml.JobDefinition) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey)

Aggregations

JobDefinition (org.finra.herd.model.api.xml.JobDefinition)24 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)9 JobAction (org.finra.herd.model.api.xml.JobAction)9 JobDefinitionCreateRequest (org.finra.herd.model.api.xml.JobDefinitionCreateRequest)9 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)9 Parameter (org.finra.herd.model.api.xml.Parameter)9 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)8 Job (org.finra.herd.model.api.xml.Job)7 StorageEntity (org.finra.herd.model.jpa.StorageEntity)6 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)5 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)5 JobDefinitionUpdateRequest (org.finra.herd.model.api.xml.JobDefinitionUpdateRequest)4 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)4 InputStream (java.io.InputStream)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 JobCreateRequest (org.finra.herd.model.api.xml.JobCreateRequest)1 BusinessObjectDataNotificationEventParamsDto (org.finra.herd.model.dto.BusinessObjectDataNotificationEventParamsDto)1 StorageUnitNotificationEventParamsDto (org.finra.herd.model.dto.StorageUnitNotificationEventParamsDto)1