use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class NotificationRegistrationDaoTestHelper method createStorageUnitNotificationRegistrationEntity.
/**
* Creates and persists a storage unit 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 newStorageUnitStatus the new storage unit status
* @param oldStorageUnitStatus the old storage unit status
* @param jobActions the list of job actions
* @param notificationRegistrationStatus the notification registration status
*
* @return the newly created storage unit notification registration entity
*/
public StorageUnitNotificationRegistrationEntity createStorageUnitNotificationRegistrationEntity(NotificationRegistrationKey notificationRegistrationKey, String notificationEventTypeCode, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, Integer businessObjectFormatVersion, String storageName, String newStorageUnitStatus, String oldStorageUnitStatus, 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.
StorageEntity storageEntity = storageDao.getStorageByName(storageName);
if (storageEntity == null) {
storageEntity = storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3);
}
// Create a business object status entity for new status if needed.
StorageUnitStatusEntity newStorageUnitStatusEntity = null;
if (StringUtils.isNotBlank(newStorageUnitStatus)) {
newStorageUnitStatusEntity = storageUnitStatusDao.getStorageUnitStatusByCode(newStorageUnitStatus);
if (newStorageUnitStatusEntity == null) {
newStorageUnitStatusEntity = storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(newStorageUnitStatus);
}
}
// Create a business object status entity for new status if needed.
StorageUnitStatusEntity oldStorageUnitStatusEntity = null;
if (StringUtils.isNotBlank(oldStorageUnitStatus)) {
oldStorageUnitStatusEntity = storageUnitStatusDao.getStorageUnitStatusByCode(oldStorageUnitStatus);
if (oldStorageUnitStatusEntity == null) {
oldStorageUnitStatusEntity = storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(oldStorageUnitStatus);
}
}
// 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.
StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity = new StorageUnitNotificationRegistrationEntity();
storageUnitNotificationRegistrationEntity.setNamespace(namespaceEntity);
storageUnitNotificationRegistrationEntity.setName(notificationRegistrationKey.getNotificationName());
storageUnitNotificationRegistrationEntity.setNotificationEventType(notificationEventTypeEntity);
storageUnitNotificationRegistrationEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
storageUnitNotificationRegistrationEntity.setUsage(businessObjectFormatUsage);
storageUnitNotificationRegistrationEntity.setFileType(fileTypeEntity);
storageUnitNotificationRegistrationEntity.setBusinessObjectFormatVersion(businessObjectFormatVersion);
storageUnitNotificationRegistrationEntity.setStorage(storageEntity);
storageUnitNotificationRegistrationEntity.setNewStorageUnitStatus(newStorageUnitStatusEntity);
storageUnitNotificationRegistrationEntity.setOldStorageUnitStatus(oldStorageUnitStatusEntity);
storageUnitNotificationRegistrationEntity.setNotificationRegistrationStatus(notificationRegistrationStatusEntity);
if (!CollectionUtils.isEmpty(jobActions)) {
List<NotificationActionEntity> notificationActionEntities = new ArrayList<>();
storageUnitNotificationRegistrationEntity.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(storageUnitNotificationRegistrationEntity);
notificationJobActionEntity.setJobDefinition(jobDefinitionEntity);
notificationJobActionEntity.setCorrelationData(jobAction.getCorrelationData());
}
}
return storageUnitNotificationRegistrationDao.saveAndRefresh(storageUnitNotificationRegistrationEntity);
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class BusinessObjectDataNotificationJobActionServiceTest method testGetIdentifyingInformation.
@Test
public void testGetIdentifyingInformation() throws Exception {
// Create a job definition.
JobDefinition jobDefinition = jobDefinitionServiceTestHelper.createJobDefinition(ACTIVITI_XML_LOG_VARIABLES_NO_REGEX_WITH_CLASSPATH);
// Create a job action.
List<JobAction> jobActions = new ArrayList<>();
jobActions.add(new JobAction(jobDefinition.getNamespace(), jobDefinition.getJobName(), CORRELATION_DATA));
// Create and persist a business object data notification registration entity.
BusinessObjectDataNotificationRegistrationEntity businessObjectDataNotificationRegistrationEntity = 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, null, null, jobActions, NotificationRegistrationStatusEntity.ENABLED);
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Create a business object data entity.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
// Create and initiate an instance of the business object data notification event parameters DTO.
BusinessObjectDataNotificationEventParamsDto businessObjectDataNotificationEventParams = new BusinessObjectDataNotificationEventParamsDto();
businessObjectDataNotificationEventParams.setBusinessObjectData(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity));
businessObjectDataNotificationEventParams.setBusinessObjectDataNotificationRegistration(businessObjectDataNotificationRegistrationEntity);
businessObjectDataNotificationEventParams.setEventType(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name());
businessObjectDataNotificationEventParams.setNotificationJobAction((NotificationJobActionEntity) businessObjectDataNotificationRegistrationEntity.getNotificationActions().toArray()[0]);
businessObjectDataNotificationEventParams.setStorageName(STORAGE_NAME);
// Get the notification action service for the business object data registration event.
NotificationActionService notificationActionService = notificationActionFactory.getNotificationActionHandler(NotificationTypeEntity.NOTIFICATION_TYPE_BDATA, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name());
// Validate the identifying information for the notification event.
String expectedValue = String.format("namespace: \"%s\", actionId: \"%s\" with " + businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey) + ", storageName: \"%s\"", businessObjectDataNotificationRegistrationEntity.getNamespace().getCode(), ((NotificationJobActionEntity) businessObjectDataNotificationRegistrationEntity.getNotificationActions().toArray()[0]).getId(), STORAGE_NAME);
assertEquals(expectedValue, notificationActionService.getIdentifyingInformation(businessObjectDataNotificationEventParams, businessObjectDataHelper));
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testUpdateStorageUnitNotificationRegistrationTrimParameters.
@Test
public void testUpdateStorageUnitNotificationRegistrationTrimParameters() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
// Create database entities required for testing.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(NAMESPACE, Arrays.asList(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name()), BDEF_NAMESPACE_2, BDEF_NAME_2, Arrays.asList(FORMAT_FILE_TYPE_CODE, FORMAT_FILE_TYPE_CODE_2), Arrays.asList(STORAGE_NAME, STORAGE_NAME_2), Arrays.asList(STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS_3, STORAGE_UNIT_STATUS_4), notificationRegistrationDaoTestHelper.getTestJobActions2());
// Create and persist a storage unit notification registration entity.
notificationRegistrationDaoTestHelper.createStorageUnitNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2, notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
// Update the storage unit notification using input parameters with leading and trailing empty spaces.
StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.updateStorageUnitNotificationRegistration(new NotificationRegistrationKey(addWhitespace(NAMESPACE), addWhitespace(NOTIFICATION_NAME)), new StorageUnitNotificationRegistrationUpdateRequest(addWhitespace(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name()), new StorageUnitNotificationFilter(addWhitespace(BDEF_NAMESPACE_2), addWhitespace(BDEF_NAME_2), addWhitespace(FORMAT_USAGE_CODE_2), addWhitespace(FORMAT_FILE_TYPE_CODE_2), FORMAT_VERSION_2, addWhitespace(STORAGE_NAME_2), addWhitespace(STORAGE_UNIT_STATUS_3), NO_STORAGE_UNIT_STATUS), Arrays.asList(new JobAction(addWhitespace(JOB_NAMESPACE_2), addWhitespace(JOB_NAME_2), addWhitespace(CORRELATION_DATA_2))), BLANK_TEXT + NotificationRegistrationStatusEntity.ENABLED + BLANK_TEXT));
// Validate the returned object.
assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, STORAGE_NAME_2, STORAGE_UNIT_STATUS_3, NO_STORAGE_UNIT_STATUS), Arrays.asList(new JobAction(JOB_NAMESPACE_2, JOB_NAME_2, addWhitespace(CORRELATION_DATA_2))), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testUpdateStorageUnitNotificationRegistrationMissingOptionalParametersPassedAsWhitespace.
@Test
public void testUpdateStorageUnitNotificationRegistrationMissingOptionalParametersPassedAsWhitespace() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
// Create other database entities required for testing.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(NAMESPACE, Arrays.asList(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name()), BDEF_NAMESPACE_2, BDEF_NAME_2, null, null, Arrays.asList(STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions());
// Create and persist a storage unit notification registration entity.
notificationRegistrationDaoTestHelper.createStorageUnitNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2, notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
// Update the storage unit notification without specifying any of the optional parameters (passing whitespace characters).
StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.updateStorageUnitNotificationRegistration(notificationRegistrationKey, new StorageUnitNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, BLANK_TEXT, BLANK_TEXT, null, STORAGE_NAME, BLANK_TEXT, BLANK_TEXT), Arrays.asList(new JobAction(JOB_NAMESPACE_2, JOB_NAME_2, BLANK_TEXT)), NotificationRegistrationStatusEntity.ENABLED));
// Validate the returned object.
assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, null, null, null, STORAGE_NAME, null, null), Arrays.asList(new JobAction(JOB_NAMESPACE_2, JOB_NAME_2, BLANK_TEXT)), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testUpdateStorageUnitNotificationRegistrationMissingOptionalParametersPassedAsNulls.
@Test
public void testUpdateStorageUnitNotificationRegistrationMissingOptionalParametersPassedAsNulls() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
// Create other database entities required for testing.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(NAMESPACE, Arrays.asList(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name()), BDEF_NAMESPACE_2, BDEF_NAME_2, null, null, Arrays.asList(STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions());
// Create and persist a storage unit notification registration entity.
notificationRegistrationDaoTestHelper.createStorageUnitNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2, notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
// Update the storage unit notification without specifying any of the optional parameters (passing whitespace characters).
StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.updateStorageUnitNotificationRegistration(notificationRegistrationKey, new StorageUnitNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, null, null, null, STORAGE_NAME, null, null), Arrays.asList(new JobAction(JOB_NAMESPACE_2, JOB_NAME_2, null)), NotificationRegistrationStatusEntity.ENABLED));
// Validate the returned object.
assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, null, null, null, STORAGE_NAME, null, null), Arrays.asList(new JobAction(JOB_NAMESPACE_2, JOB_NAME_2, null)), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
Aggregations