use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class BusinessObjectDataNotificationRegistrationServiceTest method testUpdateBusinessObjectDataNotificationRegistrationMissingOptionalParametersPassedAsWhitespace.
@Test
public void testUpdateBusinessObjectDataNotificationRegistrationMissingOptionalParametersPassedAsWhitespace() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
// Create other database entities required for testing.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting(NAMESPACE, Arrays.asList(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name()), BDEF_NAMESPACE_2, BDEF_NAME_2, null, null, Arrays.asList(BDATA_STATUS, BDATA_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions());
// Create and persist a business object data notification registration entity.
notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2, notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
// Update the business object data notification without specifying any of the optional parameters (passing whitespace characters).
BusinessObjectDataNotificationRegistration resultBusinessObjectDataNotificationRegistration = businessObjectDataNotificationRegistrationService.updateBusinessObjectDataNotificationRegistration(notificationRegistrationKey, new BusinessObjectDataNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, BLANK_TEXT, BLANK_TEXT, null, BLANK_TEXT, BLANK_TEXT, BLANK_TEXT), Arrays.asList(new JobAction(JOB_NAMESPACE_2, JOB_NAME_2, BLANK_TEXT)), NotificationRegistrationStatusEntity.ENABLED));
// Validate the returned object.
assertEquals(new BusinessObjectDataNotificationRegistration(resultBusinessObjectDataNotificationRegistration.getId(), notificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_RGSTN.name(), new BusinessObjectDataNotificationFilter(BDEF_NAMESPACE_2, BDEF_NAME_2, null, null, null, null, null, null), Arrays.asList(new JobAction(JOB_NAMESPACE_2, JOB_NAME_2, BLANK_TEXT)), NotificationRegistrationStatusEntity.ENABLED), resultBusinessObjectDataNotificationRegistration);
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class StorageUnitStatusChangeNotificationJobActionServiceTest 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 storage unit notification registration entity.
StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity = notificationRegistrationDaoTestHelper.createStorageUnitNotificationRegistrationEntity(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), 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, 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 storage unit notification event parameters DTO.
StorageUnitNotificationEventParamsDto storageUnitNotificationEventParamsDto = new StorageUnitNotificationEventParamsDto();
storageUnitNotificationEventParamsDto.setBusinessObjectData(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity));
storageUnitNotificationEventParamsDto.setStorageUnitNotificationRegistration(storageUnitNotificationRegistrationEntity);
storageUnitNotificationEventParamsDto.setEventType(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name());
storageUnitNotificationEventParamsDto.setNotificationJobAction((NotificationJobActionEntity) storageUnitNotificationRegistrationEntity.getNotificationActions().toArray()[0]);
storageUnitNotificationEventParamsDto.setStorageName(STORAGE_NAME);
// Get the notification action service for the storage unit status change event.
NotificationActionService notificationActionService = notificationActionFactory.getNotificationActionHandler(NotificationTypeEntity.NOTIFICATION_TYPE_STORAGE_UNIT, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name());
// Validate the identifying information for the notification event.
String expectedValue = String.format("namespace: \"%s\", actionId: \"%s\" with " + businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey) + ", storageName: \"%s\"", storageUnitNotificationRegistrationEntity.getNamespace().getCode(), ((NotificationJobActionEntity) storageUnitNotificationRegistrationEntity.getNotificationActions().toArray()[0]).getId(), STORAGE_NAME);
assertEquals(expectedValue, notificationActionService.getIdentifyingInformation(storageUnitNotificationEventParamsDto, businessObjectDataHelper));
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testUpdateStorageUnitNotificationRegistrationLowerCaseParameters.
@Test
public void testUpdateStorageUnitNotificationRegistrationLowerCaseParameters() {
// Create database entities required for testing using upper case alternate key values.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(NAMESPACE.toUpperCase(), Arrays.asList(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toUpperCase(), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toUpperCase()), BDEF_NAMESPACE_2.toUpperCase(), BDEF_NAME_2.toUpperCase(), Arrays.asList(FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE_2.toUpperCase()), Arrays.asList(STORAGE_NAME.toUpperCase(), STORAGE_NAME_2.toUpperCase()), Arrays.asList(STORAGE_UNIT_STATUS.toUpperCase(), STORAGE_UNIT_STATUS_2.toUpperCase(), STORAGE_UNIT_STATUS_3.toUpperCase(), STORAGE_UNIT_STATUS_4.toUpperCase()), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toUpperCase(), JOB_NAME_2.toUpperCase(), null)));
// Create and persist a storage unit notification registration entity using upper case alternate key values.
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE.toUpperCase(), NOTIFICATION_NAME.toUpperCase());
notificationRegistrationDaoTestHelper.createStorageUnitNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toUpperCase(), BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, STORAGE_NAME.toUpperCase(), STORAGE_UNIT_STATUS.toUpperCase(), STORAGE_UNIT_STATUS_2.toUpperCase(), Arrays.asList(new JobAction(JOB_NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase(), CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED);
// Update the storage unit notification using lower case input parameters.
StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.updateStorageUnitNotificationRegistration(new NotificationRegistrationKey(NAMESPACE.toLowerCase(), NOTIFICATION_NAME.toLowerCase()), new StorageUnitNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toLowerCase(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2.toLowerCase(), BDEF_NAME_2.toLowerCase(), FORMAT_USAGE_CODE_2.toLowerCase(), FORMAT_FILE_TYPE_CODE_2.toLowerCase(), FORMAT_VERSION_2, STORAGE_NAME_2.toLowerCase(), STORAGE_UNIT_STATUS_3.toLowerCase(), NO_STORAGE_UNIT_STATUS), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toLowerCase(), JOB_NAME_2.toLowerCase(), CORRELATION_DATA_2.toLowerCase())), "enabled"));
// Validate the returned object.
assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toUpperCase(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2.toUpperCase(), BDEF_NAME_2.toUpperCase(), FORMAT_USAGE_CODE_2.toLowerCase(), FORMAT_FILE_TYPE_CODE_2.toUpperCase(), FORMAT_VERSION_2, STORAGE_NAME_2.toUpperCase(), STORAGE_UNIT_STATUS_3.toUpperCase(), NO_STORAGE_UNIT_STATUS), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toUpperCase(), JOB_NAME_2.toUpperCase(), CORRELATION_DATA_2.toLowerCase())), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testUpdateStorageUnitNotificationRegistrationUpperCaseParameters.
@Test
public void testUpdateStorageUnitNotificationRegistrationUpperCaseParameters() {
// Create database entities required for testing using lower case alternate key values.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(NAMESPACE.toLowerCase(), Arrays.asList(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toLowerCase(), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toLowerCase()), BDEF_NAMESPACE_2.toLowerCase(), BDEF_NAME_2.toLowerCase(), Arrays.asList(FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE_2.toLowerCase()), Arrays.asList(STORAGE_NAME.toLowerCase(), STORAGE_NAME_2.toLowerCase()), Arrays.asList(STORAGE_UNIT_STATUS.toLowerCase(), STORAGE_UNIT_STATUS_2.toLowerCase(), STORAGE_UNIT_STATUS_3.toLowerCase(), STORAGE_UNIT_STATUS_4.toLowerCase()), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toLowerCase(), JOB_NAME_2.toLowerCase(), null)));
// Create and persist a storage unit notification registration entity using lower case alternate key values.
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE.toLowerCase(), NOTIFICATION_NAME.toLowerCase());
notificationRegistrationDaoTestHelper.createStorageUnitNotificationRegistrationEntity(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toLowerCase(), BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, STORAGE_NAME.toLowerCase(), STORAGE_UNIT_STATUS.toLowerCase(), STORAGE_UNIT_STATUS_2.toLowerCase(), Arrays.asList(new JobAction(JOB_NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase(), CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED);
// Update the storage unit notification using upper case input parameters.
StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.updateStorageUnitNotificationRegistration(new NotificationRegistrationKey(NAMESPACE.toUpperCase(), NOTIFICATION_NAME.toUpperCase()), new StorageUnitNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toUpperCase(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2.toUpperCase(), BDEF_NAME_2.toUpperCase(), FORMAT_USAGE_CODE_2.toUpperCase(), FORMAT_FILE_TYPE_CODE_2.toUpperCase(), FORMAT_VERSION_2, STORAGE_NAME_2.toUpperCase(), STORAGE_UNIT_STATUS_3.toUpperCase(), NO_STORAGE_UNIT_STATUS), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toUpperCase(), JOB_NAME_2.toUpperCase(), CORRELATION_DATA_2.toUpperCase())), NotificationRegistrationStatusEntity.ENABLED));
// Validate the returned object.
assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), new NotificationRegistrationKey(NAMESPACE.toLowerCase(), NOTIFICATION_NAME.toLowerCase()), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toLowerCase(), new StorageUnitNotificationFilter(BDEF_NAMESPACE_2.toLowerCase(), BDEF_NAME_2.toLowerCase(), FORMAT_USAGE_CODE_2.toUpperCase(), FORMAT_FILE_TYPE_CODE_2.toLowerCase(), FORMAT_VERSION_2, STORAGE_NAME_2.toLowerCase(), STORAGE_UNIT_STATUS_3.toLowerCase(), NO_STORAGE_UNIT_STATUS), Arrays.asList(new JobAction(JOB_NAMESPACE_2.toLowerCase(), JOB_NAME_2.toLowerCase(), CORRELATION_DATA_2.toUpperCase())), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
use of org.finra.herd.model.api.xml.JobAction in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testCreateStorageUnitNotificationRegistrationInvalidParameters.
@Test
public void testCreateStorageUnitNotificationRegistrationInvalidParameters() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
StorageUnitNotificationRegistrationCreateRequest request;
// Create and persist the relative database entities.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting();
// Try to create a storage unit notification using non-existing namespace.
request = new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey("I_DO_NOT_EXIST", NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(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);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing namespace.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Namespace \"%s\" doesn't exist.", request.getStorageUnitNotificationRegistrationKey().getNamespace()), e.getMessage());
}
// Try to create a storage unit notification when namespace contains a forward slash character.
request = new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(addSlash(NAMESPACE), NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(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);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when namespace contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Namespace can not contain a forward slash character.", e.getMessage());
}
// Try to create a storage unit notification when notification name contains a forward slash character.
request = new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, addSlash(NOTIFICATION_NAME)), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(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);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when notification name contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Notification name can not contain a forward slash character.", e.getMessage());
}
// Try to create a storage unit notification using non-existing notification event type.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, "I_DO_NOT_EXIST", new StorageUnitNotificationFilter(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);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing notification event type.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Notification event type with code \"%s\" doesn't exist.", request.getStorageUnitEventType()), e.getMessage());
}
// Try to create a storage unit notification using non-supported notification event type.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NOTIFICATION_EVENT_TYPE, new StorageUnitNotificationFilter(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);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when using non-supported notification event type.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Notification event type \"%s\" is not supported for storage unit notification registration.", request.getStorageUnitEventType()), e.getMessage());
}
// Try to create a storage unit notification using non-existing business object definition name.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing business object definition name.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Business object definition with name \"%s\" doesn't exist for namespace \"%s\".", request.getStorageUnitNotificationFilter().getBusinessObjectDefinitionName(), request.getStorageUnitNotificationFilter().getNamespace()), e.getMessage());
}
// Try to create a storage unit notification using non-existing business object format file type.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing business object format file type.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("File type with code \"%s\" doesn't exist.", request.getStorageUnitNotificationFilter().getBusinessObjectFormatFileType()), e.getMessage());
}
// Try to create a storage unit notification using non-existing storage name.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing storage name.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", request.getStorageUnitNotificationFilter().getStorageName()), e.getMessage());
}
// Try to create a storage unit notification using non-existing new storage unit status.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, "I_DO_NOT_EXIST", STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing new storage unit status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage unit status \"%s\" doesn't exist.", request.getStorageUnitNotificationFilter().getNewStorageUnitStatus()), e.getMessage());
}
// Try to create a storage unit notification using non-existing old storage unit status.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, "I_DO_NOT_EXIST"), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing old storage unit status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage unit status \"%s\" doesn't exist.", request.getStorageUnitNotificationFilter().getOldStorageUnitStatus()), e.getMessage());
}
// Try to create a storage unit notification when using new and old storage unit statuses that are the same (case-insensitive).
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS.toUpperCase(), STORAGE_UNIT_STATUS.toLowerCase()), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when using new and old storage unit statuses that are the same");
} catch (IllegalArgumentException e) {
assertEquals("The new storage unit status is the same as the old one.", e.getMessage());
}
// Try to create a storage unit notification using non-existing job definition.
request = new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), Arrays.asList(new JobAction(NAMESPACE, "I_DO_NOT_EXIST", CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing job definition.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Job definition with namespace \"%s\" and job name \"%s\" doesn't exist.", request.getJobActions().get(0).getNamespace(), request.getJobActions().get(0).getJobName()), e.getMessage());
}
// Try to create a storage unit notification using non-existing notification registration status.
request = new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), "I_DO_NOT_EXIST");
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an ObjectNotFoundException when using non-existing notification registration status.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("The notification registration status \"%s\" doesn't exist.", request.getNotificationRegistrationStatus()), e.getMessage());
}
}
Aggregations