### Question:
NotificationCreationPermissionCheckerAspect { @Around("execution(* com.sflpro.notifier.services.notification..*.create* (..)) " + "&& args(notification,..)") public <N extends NotificationDto<?>> Object aroundNotificationCreation(final ProceedingJoinPoint point, final N notification) throws Throwable { logger.debug("Checking permission for sending {} notification with subject {}", notification.getType(), notification.getSubject()); return executeAuthorized(point, notification); } NotificationCreationPermissionCheckerAspect(final NotificationCreationPermissionChecker permissionChecker); @Around("execution(* com.sflpro.notifier.services.notification..*.create* (..)) " + "&& args(notification,..)") Object aroundNotificationCreation(final ProceedingJoinPoint point, final N notification); @Around("execution(* com.sflpro.notifier.services.notification..*.createNotificationsForUserActiveRecipients* (..)) " + "&& args(userId,pushNotification,..)") Object aroundPushNotificationCreation(final ProceedingJoinPoint point, final Long userId, final PushNotificationDto pushNotification);  }### Answer:
@Test public void testAroundNotificationCreationNotAllowed() throws Throwable { final NotificationDto notification = getServiceFacadeImplTestHelper().createEmailNotificationDto(); expect(permissionChecker.isNotificationCreationAllowed(notification)).andReturn(false); replayAll(); assertThatThrownBy(() -> notificationCreationPermissionCheckerAspect.aroundNotificationCreation(proceedingJoinPoint, notification)) .isInstanceOf(PermissionDeniedException.class); verifyAll(); }
@Test public void testAroundNotificationCreationAllowed() throws Throwable { final NotificationDto notification = getServiceFacadeImplTestHelper().createEmailNotificationDto(); final EmailNotification result = new EmailNotification(); expect(permissionChecker.isNotificationCreationAllowed(notification)).andReturn(true); expect(proceedingJoinPoint.proceed()).andReturn(result); replayAll(); assertThat(notificationCreationPermissionCheckerAspect.aroundNotificationCreation(proceedingJoinPoint, notification)) .isEqualTo(result); verifyAll(); }