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;
}
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);
}
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;
}
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);
}
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);
}
Aggregations