use of org.finra.herd.model.api.xml.StorageUnitNotificationFilter in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testGetStorageUnitNotificationRegistrationsByNotificationFilterMissingOptionalParameters.
@Test
public void testGetStorageUnitNotificationRegistrationsByNotificationFilterMissingOptionalParameters() {
// Create a storage unit notification registration key.
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
// 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);
// Retrieve a list of storage unit notification registration keys by not specifying optional parameters.
assertEquals(new StorageUnitNotificationRegistrationKeys(Arrays.asList(notificationRegistrationKey)), storageUnitNotificationRegistrationService.getStorageUnitNotificationRegistrationsByNotificationFilter(new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, NO_FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, NO_STORAGE_NAME, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS)));
assertEquals(new StorageUnitNotificationRegistrationKeys(Arrays.asList(notificationRegistrationKey)), storageUnitNotificationRegistrationService.getStorageUnitNotificationRegistrationsByNotificationFilter(new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, NO_FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, NO_STORAGE_NAME, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS)));
}
use of org.finra.herd.model.api.xml.StorageUnitNotificationFilter in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testCreateStorageUnitNotificationRegistrationUpperCaseParameters.
@Test
public void testCreateStorageUnitNotificationRegistrationUpperCaseParameters() {
// Create and persist the relative database entities using lower case values.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(NAMESPACE.toLowerCase(), Arrays.asList(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name()), BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), Arrays.asList(FORMAT_FILE_TYPE_CODE.toLowerCase()), Arrays.asList(STORAGE_NAME.toLowerCase()), Arrays.asList(STORAGE_UNIT_STATUS.toLowerCase(), STORAGE_UNIT_STATUS_2.toLowerCase()), Arrays.asList(new JobAction(NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase(), BLANK_TEXT)));
// Create a storage unit notification using upper case input parameters.
StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE.toUpperCase(), NOTIFICATION_NAME.toUpperCase()), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().toUpperCase(), new StorageUnitNotificationFilter(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(NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase(), CORRELATION_DATA.toUpperCase())), NotificationRegistrationStatusEntity.ENABLED.toUpperCase()));
// Validate the returned object.
assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), new NotificationRegistrationKey(NAMESPACE.toLowerCase(), NOTIFICATION_NAME.toUpperCase()), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, STORAGE_NAME.toLowerCase(), STORAGE_UNIT_STATUS.toLowerCase(), STORAGE_UNIT_STATUS_2.toLowerCase()), Arrays.asList(new JobAction(NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase(), CORRELATION_DATA.toUpperCase())), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
use of org.finra.herd.model.api.xml.StorageUnitNotificationFilter in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testCreateStorageUnitNotificationRegistrationDuplicateJobActions.
@Test
public void testCreateStorageUnitNotificationRegistrationDuplicateJobActions() {
// Create and persist the relative database entities.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting();
// Try to create a storage unit notification with duplicate job actions.
StorageUnitNotificationRegistrationCreateRequest request = new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(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.toLowerCase(), JOB_NAME.toLowerCase(), CORRELATION_DATA), new JobAction(NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase(), CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED);
try {
storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request);
fail("Should throw an IllegalArgumentException when create request contains duplicate job actions.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Duplicate job action {namespace: \"%s\", jobName: \"%s\"} found.", request.getJobActions().get(1).getNamespace(), request.getJobActions().get(1).getJobName()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageUnitNotificationFilter in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testGetStorageUnitNotificationRegistrationsByNotificationFilterUpperCaseParameters.
@Test
public void testGetStorageUnitNotificationRegistrationsByNotificationFilterUpperCaseParameters() {
// Create a storage unit notification registration key.
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
// 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);
// Retrieve a list of storage unit notification registration keys using upper case input parameters.
assertEquals(new StorageUnitNotificationRegistrationKeys(Arrays.asList(notificationRegistrationKey)), storageUnitNotificationRegistrationService.getStorageUnitNotificationRegistrationsByNotificationFilter(new StorageUnitNotificationFilter(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), NO_FORMAT_VERSION, NO_STORAGE_NAME, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS)));
}
use of org.finra.herd.model.api.xml.StorageUnitNotificationFilter in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationServiceTest method testUpdateStorageUnitNotificationRegistrationInvalidParameters.
@Test
public void testUpdateStorageUnitNotificationRegistrationInvalidParameters() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
StorageUnitNotificationRegistrationUpdateRequest request;
// Create and persist the relative database entities.
notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(NAMESPACE, Arrays.asList(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), NOTIFICATION_EVENT_TYPE), 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);
// Try to update a storage unit notification using non-existing notification event type.
request = new StorageUnitNotificationRegistrationUpdateRequest("I_DO_NOT_EXIST", new StorageUnitNotificationFilter(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification using non-supported notification event type.
request = new StorageUnitNotificationRegistrationUpdateRequest(NOTIFICATION_EVENT_TYPE, new StorageUnitNotificationFilter(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification using non-existing business object definition name.
request = new StorageUnitNotificationRegistrationUpdateRequest(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification using non-existing business object format file type.
request = new StorageUnitNotificationRegistrationUpdateRequest(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification using non-existing storage name.
request = new StorageUnitNotificationRegistrationUpdateRequest(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification using non-existing new storage unit status.
request = new StorageUnitNotificationRegistrationUpdateRequest(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification using non-existing old storage unit status.
request = new StorageUnitNotificationRegistrationUpdateRequest(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 StorageUnitNotificationRegistrationUpdateRequest(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification registration using non-existing job definition.
request = new StorageUnitNotificationRegistrationUpdateRequest(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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 update a storage unit notification using non-existing notification registration status.
request = new StorageUnitNotificationRegistrationUpdateRequest(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.updateStorageUnitNotificationRegistration(notificationRegistrationKey, 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