Search in sources :

Example 31 with JobAction

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

the class NotificationRegistrationDaoTestHelper method getTestJobActions.

/**
 * Returns a list of test job actions.
 *
 * @return the list of test job actions
 */
public List<JobAction> getTestJobActions() {
    List<JobAction> jobActions = new ArrayList<>();
    jobActions.add(new JobAction(AbstractDaoTest.JOB_NAMESPACE, AbstractDaoTest.JOB_NAME, AbstractDaoTest.CORRELATION_DATA));
    jobActions.add(new JobAction(AbstractDaoTest.JOB_NAMESPACE_2, AbstractDaoTest.JOB_NAME_2, AbstractDaoTest.CORRELATION_DATA_2));
    return jobActions;
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) ArrayList(java.util.ArrayList)

Example 32 with JobAction

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

the class NotificationRegistrationDaoTestHelper method createBusinessObjectDataNotificationRegistrationEntity.

/**
 * Creates and persists a business object data notification registration entity.
 *
 * @param notificationRegistrationKey the business object data notification registration key
 * @param notificationEventTypeCode the notification event type
 * @param businessObjectDefinitionNamespace the business object definition namespace
 * @param businessObjectDefinitionName the business object definition name
 * @param businessObjectFormatUsage the business object usage
 * @param businessObjectFormatFileType the business object format file type
 * @param businessObjectFormatVersion the business object format version
 * @param storageName the storage name
 * @param newBusinessObjectDataStatus the new business object data status
 * @param oldBusinessObjectDataStatus the old business object data status
 * @param jobActions the list of job actions
 * @param notificationRegistrationStatus the notification registration status
 *
 * @return the newly created business object data notification registration entity
 */
public BusinessObjectDataNotificationRegistrationEntity createBusinessObjectDataNotificationRegistrationEntity(NotificationRegistrationKey notificationRegistrationKey, String notificationEventTypeCode, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, Integer businessObjectFormatVersion, String storageName, String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus, List<JobAction> jobActions, String notificationRegistrationStatus) {
    // Create a namespace entity if needed.
    NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(notificationRegistrationKey.getNamespace());
    if (namespaceEntity == null) {
        namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(notificationRegistrationKey.getNamespace());
    }
    // Create a notification event type entity if needed.
    NotificationEventTypeEntity notificationEventTypeEntity = notificationEventTypeDao.getNotificationEventTypeByCode(notificationEventTypeCode);
    if (notificationEventTypeEntity == null) {
        notificationEventTypeEntity = createNotificationEventTypeEntity(notificationEventTypeCode);
    }
    // Create a business object definition entity if needed.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(businessObjectDefinitionNamespace, businessObjectDefinitionName));
    if (businessObjectDefinitionEntity == null) {
        businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionNamespace, businessObjectDefinitionName, AbstractDaoTest.DATA_PROVIDER_NAME, AbstractDaoTest.BDEF_DESCRIPTION);
    }
    // Create a business object format file type entity if needed.
    FileTypeEntity fileTypeEntity = null;
    if (StringUtils.isNotBlank(businessObjectFormatFileType)) {
        fileTypeEntity = fileTypeDao.getFileTypeByCode(businessObjectFormatFileType);
        if (fileTypeEntity == null) {
            fileTypeEntity = fileTypeDaoTestHelper.createFileTypeEntity(businessObjectFormatFileType);
        }
    }
    // Create a storage entity if needed.
    StorageEntity storageEntity = null;
    if (StringUtils.isNotBlank(storageName)) {
        storageEntity = storageDao.getStorageByName(storageName);
        if (storageEntity == null) {
            storageEntity = storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3);
        }
    }
    // Create a business object status entity for new status if needed.
    BusinessObjectDataStatusEntity newBusinessObjectDataStatusEntity = null;
    if (StringUtils.isNotBlank(newBusinessObjectDataStatus)) {
        newBusinessObjectDataStatusEntity = businessObjectDataStatusDao.getBusinessObjectDataStatusByCode(newBusinessObjectDataStatus);
        if (newBusinessObjectDataStatusEntity == null) {
            newBusinessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(newBusinessObjectDataStatus);
        }
    }
    // Create a business object status entity for new status if needed.
    BusinessObjectDataStatusEntity oldBusinessObjectDataStatusEntity = null;
    if (StringUtils.isNotBlank(oldBusinessObjectDataStatus)) {
        oldBusinessObjectDataStatusEntity = businessObjectDataStatusDao.getBusinessObjectDataStatusByCode(oldBusinessObjectDataStatus);
        if (oldBusinessObjectDataStatusEntity == null) {
            oldBusinessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(oldBusinessObjectDataStatus);
        }
    }
    // Create a notification registration status entity if needed.
    NotificationRegistrationStatusEntity notificationRegistrationStatusEntity = notificationRegistrationStatusDao.getNotificationRegistrationStatus(notificationRegistrationStatus);
    if (notificationRegistrationStatusEntity == null) {
        notificationRegistrationStatusEntity = createNotificationRegistrationStatusEntity(notificationRegistrationStatus);
    }
    // Create a business object data notification registration entity.
    BusinessObjectDataNotificationRegistrationEntity businessObjectDataNotificationRegistrationEntity = new BusinessObjectDataNotificationRegistrationEntity();
    businessObjectDataNotificationRegistrationEntity.setNamespace(namespaceEntity);
    businessObjectDataNotificationRegistrationEntity.setName(notificationRegistrationKey.getNotificationName());
    businessObjectDataNotificationRegistrationEntity.setNotificationEventType(notificationEventTypeEntity);
    businessObjectDataNotificationRegistrationEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
    businessObjectDataNotificationRegistrationEntity.setUsage(businessObjectFormatUsage);
    businessObjectDataNotificationRegistrationEntity.setFileType(fileTypeEntity);
    businessObjectDataNotificationRegistrationEntity.setBusinessObjectFormatVersion(businessObjectFormatVersion);
    businessObjectDataNotificationRegistrationEntity.setStorage(storageEntity);
    businessObjectDataNotificationRegistrationEntity.setNewBusinessObjectDataStatus(newBusinessObjectDataStatusEntity);
    businessObjectDataNotificationRegistrationEntity.setOldBusinessObjectDataStatus(oldBusinessObjectDataStatusEntity);
    businessObjectDataNotificationRegistrationEntity.setNotificationRegistrationStatus(notificationRegistrationStatusEntity);
    if (!CollectionUtils.isEmpty(jobActions)) {
        List<NotificationActionEntity> notificationActionEntities = new ArrayList<>();
        businessObjectDataNotificationRegistrationEntity.setNotificationActions(notificationActionEntities);
        for (JobAction jobAction : jobActions) {
            // Create a job definition entity if needed.
            JobDefinitionEntity jobDefinitionEntity = jobDefinitionDao.getJobDefinitionByAltKey(jobAction.getNamespace(), jobAction.getJobName());
            if (jobDefinitionEntity == null) {
                jobDefinitionEntity = jobDefinitionDaoTestHelper.createJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName(), String.format("Description of \"%s.%s\" job definition.", jobAction.getNamespace(), jobAction.getJobName()), String.format("%s.%s.%s", jobAction.getNamespace(), jobAction.getJobName(), AbstractDaoTest.ACTIVITI_ID));
            }
            NotificationJobActionEntity notificationJobActionEntity = new NotificationJobActionEntity();
            notificationActionEntities.add(notificationJobActionEntity);
            notificationJobActionEntity.setNotificationRegistration(businessObjectDataNotificationRegistrationEntity);
            notificationJobActionEntity.setJobDefinition(jobDefinitionEntity);
            notificationJobActionEntity.setCorrelationData(jobAction.getCorrelationData());
        }
    }
    return businessObjectDataNotificationRegistrationDao.saveAndRefresh(businessObjectDataNotificationRegistrationEntity);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) BusinessObjectDataStatusEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusEntity) ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity) NotificationJobActionEntity(org.finra.herd.model.jpa.NotificationJobActionEntity) NotificationEventTypeEntity(org.finra.herd.model.jpa.NotificationEventTypeEntity) JobDefinitionEntity(org.finra.herd.model.jpa.JobDefinitionEntity) JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) NotificationRegistrationStatusEntity(org.finra.herd.model.jpa.NotificationRegistrationStatusEntity) BusinessObjectDataNotificationRegistrationEntity(org.finra.herd.model.jpa.BusinessObjectDataNotificationRegistrationEntity) NotificationActionEntity(org.finra.herd.model.jpa.NotificationActionEntity)

Example 33 with JobAction

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

the class NotificationRegistrationDaoTestHelper method getTestJobActions2.

/**
 * Returns a list of test job actions.
 *
 * @return the list of test job actions
 */
public List<JobAction> getTestJobActions2() {
    List<JobAction> jobActions = new ArrayList<>();
    jobActions.add(new JobAction(AbstractDaoTest.JOB_NAMESPACE_3, AbstractDaoTest.JOB_NAME_3, AbstractDaoTest.CORRELATION_DATA_3));
    return jobActions;
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) ArrayList(java.util.ArrayList)

Example 34 with JobAction

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

the class BusinessObjectDataNotificationRegistrationRestControllerTest method testCreateBusinessObjectDataNotificationRegistration.

@Test
public void testCreateBusinessObjectDataNotificationRegistration() {
    // Create a notification registration key.
    NotificationRegistrationKey businessObjectDataNotificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
    // Create a business object data notification filter.
    BusinessObjectDataNotificationFilter businessObjectDataNotificationFilter = new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2);
    // Create a list of job actions.
    List<JobAction> jobActions = Arrays.asList(new JobAction(JOB_NAMESPACE, JOB_NAME, CORRELATION_DATA));
    // Create a business object data notification registration create request.
    BusinessObjectDataNotificationRegistrationCreateRequest businessObjectDataNotificationRegistrationCreateRequest = new BusinessObjectDataNotificationRegistrationCreateRequest(businessObjectDataNotificationRegistrationKey, NOTIFICATION_EVENT_TYPE, businessObjectDataNotificationFilter, jobActions, NOTIFICATION_REGISTRATION_STATUS);
    // Create a business object data notification registration.
    BusinessObjectDataNotificationRegistration businessObjectDataNotificationRegistration = new BusinessObjectDataNotificationRegistration(ID, businessObjectDataNotificationRegistrationKey, NOTIFICATION_EVENT_TYPE, businessObjectDataNotificationFilter, jobActions, NOTIFICATION_REGISTRATION_STATUS);
    // Mock the external calls.
    when(businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistrationCreateRequest)).thenReturn(businessObjectDataNotificationRegistration);
    // Call the method under test.
    BusinessObjectDataNotificationRegistration result = businessObjectDataNotificationRegistrationRestController.createBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistrationCreateRequest);
    // Verify the external calls.
    verify(businessObjectDataNotificationRegistrationService).createBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistrationCreateRequest);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataNotificationRegistration, result);
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDataNotificationRegistrationCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationCreateRequest) BusinessObjectDataNotificationFilter(org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter) BusinessObjectDataNotificationRegistration(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 35 with JobAction

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

the class BusinessObjectDataNotificationRegistrationRestControllerTest method testDeleteBusinessObjectDataNotificationRegistration.

@Test
public void testDeleteBusinessObjectDataNotificationRegistration() {
    // Create a notification registration key.
    NotificationRegistrationKey businessObjectDataNotificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
    // Create a business object data notification filter.
    BusinessObjectDataNotificationFilter businessObjectDataNotificationFilter = new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2);
    // Create a list of job actions.
    List<JobAction> jobActions = Arrays.asList(new JobAction(JOB_NAMESPACE, JOB_NAME, CORRELATION_DATA));
    // Create a business object data notification registration.
    BusinessObjectDataNotificationRegistration businessObjectDataNotificationRegistration = new BusinessObjectDataNotificationRegistration(ID, businessObjectDataNotificationRegistrationKey, NOTIFICATION_EVENT_TYPE, businessObjectDataNotificationFilter, jobActions, NOTIFICATION_REGISTRATION_STATUS);
    // Mock the external calls.
    when(businessObjectDataNotificationRegistrationService.deleteBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistrationKey)).thenReturn(businessObjectDataNotificationRegistration);
    // Call the method under test.
    BusinessObjectDataNotificationRegistration result = businessObjectDataNotificationRegistrationRestController.deleteBusinessObjectDataNotification(NAMESPACE, NOTIFICATION_NAME);
    // Verify the external calls.
    verify(businessObjectDataNotificationRegistrationService).deleteBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistrationKey);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataNotificationRegistration, result);
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDataNotificationFilter(org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter) BusinessObjectDataNotificationRegistration(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Aggregations

JobAction (org.finra.herd.model.api.xml.JobAction)59 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)49 Test (org.junit.Test)41 BusinessObjectDataNotificationFilter (org.finra.herd.model.api.xml.BusinessObjectDataNotificationFilter)23 StorageUnitNotificationFilter (org.finra.herd.model.api.xml.StorageUnitNotificationFilter)17 ArrayList (java.util.ArrayList)15 BusinessObjectDataNotificationRegistration (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistration)15 StorageEntity (org.finra.herd.model.jpa.StorageEntity)12 BusinessObjectDataNotificationRegistrationCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationCreateRequest)11 StorageUnitNotificationRegistration (org.finra.herd.model.api.xml.StorageUnitNotificationRegistration)11 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)9 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)8 StorageUnitNotificationRegistrationCreateRequest (org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest)8 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)8 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)8 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)8 NotificationEventTypeEntity (org.finra.herd.model.jpa.NotificationEventTypeEntity)8 BusinessObjectDataNotificationRegistrationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationUpdateRequest)7 Job (org.finra.herd.model.api.xml.Job)6