Search in sources :

Example 6 with StorageUnitNotificationRegistrationCreateRequest

use of org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest 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());
    }
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) StorageUnitNotificationRegistrationCreateRequest(org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest) StorageUnitNotificationFilter(org.finra.herd.model.api.xml.StorageUnitNotificationFilter) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 7 with StorageUnitNotificationRegistrationCreateRequest

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

the class StorageUnitNotificationRegistrationServiceTest method testCreateStorageUnitNotificationRegistrationAlreadyExists.

@Test
public void testCreateStorageUnitNotificationRegistrationAlreadyExists() {
    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(), 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 create a storage unit notification when it already exists.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, 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), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an AlreadyExistsException when storage unit notification already exists.");
    } catch (AlreadyExistsException e) {
        assertEquals(String.format("Unable to create storage unit notification with name \"%s\" because it already exists for namespace \"%s\".", notificationRegistrationKey.getNotificationName(), notificationRegistrationKey.getNamespace()), e.getMessage());
    }
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) StorageUnitNotificationRegistrationCreateRequest(org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest) StorageUnitNotificationFilter(org.finra.herd.model.api.xml.StorageUnitNotificationFilter) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 8 with StorageUnitNotificationRegistrationCreateRequest

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

the class StorageUnitNotificationRegistrationServiceTest method testCreateStorageUnitNotificationRegistrationMissingRequiredParameters.

@Test
public void testCreateStorageUnitNotificationRegistrationMissingRequiredParameters() {
    NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
    // Try to create a storage unit notification instance when namespace is not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(BLANK_TEXT, 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), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an IllegalArgumentException when namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to create a storage unit notification instance when notification name is not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, BLANK_TEXT), 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), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an IllegalArgumentException when notification name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A notification name must be specified.", e.getMessage());
    }
    // Try to create a storage unit notification instance when storage unit notification event type is not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, BLANK_TEXT, 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));
        fail("Should throw an IllegalArgumentException when storage unit notification event type is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage unit event type must be specified.", e.getMessage());
    }
    // Try to create a storage unit notification instance when object definition name is not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to create a storage unit notification instance when storage name is not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, BLANK_TEXT, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an IllegalArgumentException when storage name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A storage name must be specified.", e.getMessage());
    }
    // Try to create a storage unit notification instance when job actions are not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, 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), null, NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an IllegalArgumentException when job actions are not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("At least one notification action must be specified.", e.getMessage());
    }
    // Try to create a storage unit notification instance when job action job namespace is not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, 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(BLANK_TEXT, JOB_NAME, CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an IllegalArgumentException when job action job namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A job action namespace must be specified.", e.getMessage());
    }
    // Try to create a storage unit notification instance when job action job name is not specified.
    try {
        storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, 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, BLANK_TEXT, CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED));
        fail("Should throw an IllegalArgumentException when job action job name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A job action job name must be specified.", e.getMessage());
    }
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) StorageUnitNotificationRegistrationCreateRequest(org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest) StorageUnitNotificationFilter(org.finra.herd.model.api.xml.StorageUnitNotificationFilter) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 9 with StorageUnitNotificationRegistrationCreateRequest

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

the class StorageUnitNotificationRegistrationServiceTest method testCreateStorageUnitNotificationRegistrationTrimParameters.

@Test
public void testCreateStorageUnitNotificationRegistrationTrimParameters() {
    // Create and persist the relative database entities.
    notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting();
    // Create a storage unit notification using input parameters with leading and trailing empty spaces.
    StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(addWhitespace(NAMESPACE), addWhitespace(NOTIFICATION_NAME)), addWhitespace(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name()), new StorageUnitNotificationFilter(addWhitespace(BDEF_NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, addWhitespace(STORAGE_NAME), addWhitespace(STORAGE_UNIT_STATUS), addWhitespace(STORAGE_UNIT_STATUS_2)), Arrays.asList(new JobAction(addWhitespace(JOB_NAMESPACE), addWhitespace(JOB_NAME), addWhitespace(CORRELATION_DATA))), addWhitespace(NotificationRegistrationStatusEntity.ENABLED)));
    // Validate the returned object.
    assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), 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), Arrays.asList(new JobAction(JOB_NAMESPACE, JOB_NAME, addWhitespace(CORRELATION_DATA))), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) StorageUnitNotificationRegistrationCreateRequest(org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest) StorageUnitNotificationRegistration(org.finra.herd.model.api.xml.StorageUnitNotificationRegistration) StorageUnitNotificationFilter(org.finra.herd.model.api.xml.StorageUnitNotificationFilter) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Example 10 with StorageUnitNotificationRegistrationCreateRequest

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

the class StorageUnitNotificationRegistrationServiceTest method testCreateStorageUnitNotificationRegistrationMissingOptionalParametersPassedAsNulls.

@Test
public void testCreateStorageUnitNotificationRegistrationMissingOptionalParametersPassedAsNulls() {
    NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
    // Create a business object definition.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
    // Create and persist the relative database entities.
    notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting();
    // Create a storage unit notification without specifying any of the optional parameters (passing null values).
    StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(new StorageUnitNotificationRegistrationCreateRequest(notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, null, null, null, STORAGE_NAME, null, null), Arrays.asList(new JobAction(JOB_NAMESPACE, JOB_NAME, null)), null));
    // Validate the returned object.
    assertEquals(new StorageUnitNotificationRegistration(resultStorageUnitNotificationRegistration.getId(), notificationRegistrationKey, NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, null, null, null, STORAGE_NAME, null, null), Arrays.asList(new JobAction(JOB_NAMESPACE, JOB_NAME, null)), NotificationRegistrationStatusEntity.ENABLED), resultStorageUnitNotificationRegistration);
}
Also used : JobAction(org.finra.herd.model.api.xml.JobAction) StorageUnitNotificationRegistrationCreateRequest(org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest) StorageUnitNotificationRegistration(org.finra.herd.model.api.xml.StorageUnitNotificationRegistration) StorageUnitNotificationFilter(org.finra.herd.model.api.xml.StorageUnitNotificationFilter) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) Test(org.junit.Test)

Aggregations

NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)11 StorageUnitNotificationFilter (org.finra.herd.model.api.xml.StorageUnitNotificationFilter)11 StorageUnitNotificationRegistrationCreateRequest (org.finra.herd.model.api.xml.StorageUnitNotificationRegistrationCreateRequest)11 Test (org.junit.Test)11 JobAction (org.finra.herd.model.api.xml.JobAction)8 StorageUnitNotificationRegistration (org.finra.herd.model.api.xml.StorageUnitNotificationRegistration)7 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1