use of org.finra.herd.model.api.xml.NotificationRegistrationKey in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationRestControllerTest method testUpdateStorageUnitNotificationRegistration.
@Test
public void testUpdateStorageUnitNotificationRegistration() {
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
StorageUnitNotificationRegistration storageUnitNotificationRegistration = new StorageUnitNotificationRegistration(ID, 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, STORAGE_UNIT_STATUS_4), notificationRegistrationDaoTestHelper.getTestJobActions2(), NotificationRegistrationStatusEntity.DISABLED);
StorageUnitNotificationRegistrationUpdateRequest request = new StorageUnitNotificationRegistrationUpdateRequest(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, STORAGE_UNIT_STATUS_4), notificationRegistrationDaoTestHelper.getTestJobActions2(), NotificationRegistrationStatusEntity.DISABLED);
when(storageUnitNotificationRegistrationService.updateStorageUnitNotificationRegistration(notificationRegistrationKey, request)).thenReturn(storageUnitNotificationRegistration);
// Update the business object data notification registration.
StorageUnitNotificationRegistration resultStorageUnitNotificationRegistration = storageUnitNotificationRegistrationRestController.updateStorageUnitNotificationRegistration(NAMESPACE, NOTIFICATION_NAME, request);
// Verify the external calls.
verify(storageUnitNotificationRegistrationService).updateStorageUnitNotificationRegistration(notificationRegistrationKey, request);
verifyNoMoreInteractions(storageUnitNotificationRegistrationService);
// Validate the returned object.
assertEquals(storageUnitNotificationRegistration, resultStorageUnitNotificationRegistration);
}
use of org.finra.herd.model.api.xml.NotificationRegistrationKey in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationRestControllerTest method testGetStorageUnitNotificationRegistrationsByNotificationFilterMissingOptionalParameters.
@Test
public void testGetStorageUnitNotificationRegistrationsByNotificationFilterMissingOptionalParameters() {
// Create a business object data notification registration key.
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
StorageUnitNotificationRegistrationKeys storageUnitNotificationRegistrationKeys = new StorageUnitNotificationRegistrationKeys(Arrays.asList(notificationRegistrationKey));
StorageUnitNotificationFilter storageUnitNotificationFilter = new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, NO_FORMAT_USAGE_CODE, NO_FORMAT_FILE_TYPE_CODE, null, null, null, null);
when(storageUnitNotificationRegistrationService.getStorageUnitNotificationRegistrationsByNotificationFilter(storageUnitNotificationFilter)).thenReturn(storageUnitNotificationRegistrationKeys);
// Retrieve a list of business object data notification registration keys by not specifying optional parameters.
StorageUnitNotificationRegistrationKeys resultStorageUnitNotificationRegistrationKeys = storageUnitNotificationRegistrationRestController.getStorageUnitNotificationRegistrationsByNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, NO_FORMAT_USAGE_CODE, NO_FORMAT_FILE_TYPE_CODE, getServletRequestWithNotificationFilterParameters());
// Verify the external calls.
verify(storageUnitNotificationRegistrationService).getStorageUnitNotificationRegistrationsByNotificationFilter(storageUnitNotificationFilter);
verifyNoMoreInteractions(storageUnitNotificationRegistrationService);
// Validate the returned object.
assertEquals(storageUnitNotificationRegistrationKeys, resultStorageUnitNotificationRegistrationKeys);
}
use of org.finra.herd.model.api.xml.NotificationRegistrationKey in project herd by FINRAOS.
the class StorageUnitNotificationRegistrationRestControllerTest method testGetStorageUnitNotificationRegistrationsByNotificationFilter.
@Test
public void testGetStorageUnitNotificationRegistrationsByNotificationFilter() {
// Create a business object data notification registration key.
NotificationRegistrationKey notificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME);
StorageUnitNotificationRegistrationKeys storageUnitNotificationRegistrationKeys = new StorageUnitNotificationRegistrationKeys(Arrays.asList(notificationRegistrationKey));
StorageUnitNotificationFilter storageUnitNotificationFilter = new StorageUnitNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null, null, null, null);
when(storageUnitNotificationRegistrationService.getStorageUnitNotificationRegistrationsByNotificationFilter(storageUnitNotificationFilter)).thenReturn(storageUnitNotificationRegistrationKeys);
// Retrieve a list of business object data notification registration keys.
StorageUnitNotificationRegistrationKeys resultStorageUnitNotificationRegistrationKeys = storageUnitNotificationRegistrationRestController.getStorageUnitNotificationRegistrationsByNotificationFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, getServletRequestWithNotificationFilterParameters());
// Verify the external calls.
verify(storageUnitNotificationRegistrationService).getStorageUnitNotificationRegistrationsByNotificationFilter(storageUnitNotificationFilter);
verifyNoMoreInteractions(storageUnitNotificationRegistrationService);
// Validate the returned object.
assertEquals(storageUnitNotificationRegistrationKeys, resultStorageUnitNotificationRegistrationKeys);
}
use of org.finra.herd.model.api.xml.NotificationRegistrationKey in project herd by FINRAOS.
the class NamespaceSecurityAdviceTest method checkPermissionAssertNoExceptionWhenComplexCaseAndUserHasAllPermissions.
@Test
public void checkPermissionAssertNoExceptionWhenComplexCaseAndUserHasAllPermissions() throws Exception {
// Mock a join point of the method call
// mockMethod(request);
JoinPoint joinPoint = mock(JoinPoint.class);
MethodSignature methodSignature = mock(MethodSignature.class);
Method method = NamespaceSecurityAdviceTest.class.getDeclaredMethod("mockMethod", BusinessObjectDataNotificationRegistrationCreateRequest.class);
when(methodSignature.getParameterNames()).thenReturn(new String[] { "request" });
when(methodSignature.getMethod()).thenReturn(method);
when(joinPoint.getSignature()).thenReturn(methodSignature);
BusinessObjectDataNotificationRegistrationCreateRequest request = new BusinessObjectDataNotificationRegistrationCreateRequest();
request.setBusinessObjectDataNotificationRegistrationKey(new NotificationRegistrationKey("ns1", null));
request.setBusinessObjectDataNotificationFilter(new BusinessObjectDataNotificationFilter("ns2", null, null, null, null, null, null, null));
request.setJobActions(Arrays.asList(new JobAction("ns3", null, null), new JobAction("ns4", null, null)));
when(joinPoint.getArgs()).thenReturn(new Object[] { request });
String userId = "userId";
ApplicationUser applicationUser = new ApplicationUser(getClass());
applicationUser.setUserId(userId);
applicationUser.setNamespaceAuthorizations(new HashSet<>());
applicationUser.getNamespaceAuthorizations().add(new NamespaceAuthorization("ns1", Arrays.asList(NamespacePermissionEnum.WRITE)));
applicationUser.getNamespaceAuthorizations().add(new NamespaceAuthorization("ns2", Arrays.asList(NamespacePermissionEnum.READ)));
applicationUser.getNamespaceAuthorizations().add(new NamespaceAuthorization("ns3", Arrays.asList(NamespacePermissionEnum.EXECUTE)));
applicationUser.getNamespaceAuthorizations().add(new NamespaceAuthorization("ns4", Arrays.asList(NamespacePermissionEnum.EXECUTE)));
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken(new SecurityUserWrapper(userId, "", false, false, false, false, Arrays.asList(), applicationUser), null));
try {
namespaceSecurityAdvice.checkPermission(joinPoint);
} catch (AccessDeniedException e) {
fail();
}
}
use of org.finra.herd.model.api.xml.NotificationRegistrationKey in project herd by FINRAOS.
the class NotificationRegistrationDaoHelperTest method testGetNotificationRegistrationAssertThrowWhenEntityNotExist.
@Test
public void testGetNotificationRegistrationAssertThrowWhenEntityNotExist() {
NotificationRegistrationKey businessObjectDataNotificationRegistrationKey = new NotificationRegistrationKey(NAMESPACE, BDEF_NAME);
notificationRegistrationDaoTestHelper.createBusinessObjectDataNotificationRegistrationEntity(businessObjectDataNotificationRegistrationKey, NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS, notificationRegistrationDaoTestHelper.getTestJobActions(), NotificationRegistrationStatusEntity.ENABLED);
try {
notificationRegistrationDaoHelper.getNotificationRegistration(NAMESPACE, "DOES_NOT_EXIST");
fail();
} catch (Exception e) {
assertEquals(ObjectNotFoundException.class, e.getClass());
assertEquals("The notification registration with namespace \"" + NAMESPACE + "\" and name \"DOES_NOT_EXIST\" was not found.", e.getMessage());
}
}
Aggregations