### Question:
UserNotificationServiceImpl implements UserNotificationService { @Nonnull @Override public UserNotification getUserNotificationById(@Nonnull final Long userNotificationId) { assertUserNotificationIdNotNull(userNotificationId); LOGGER.debug("Getting user notification for id - {}", userNotificationId); final UserNotification userNotification = userNotificationRepository.findById(userNotificationId).orElseThrow(() -> new UserNotificationNotFoundForIdException(userNotificationId)); LOGGER.debug("Successfully retrieved user notification for id - {}, user notification - {}", userNotification.getId(), userNotification); return userNotification; } UserNotificationServiceImpl(); @Transactional @Nonnull @Override UserNotification createUserNotification(@Nonnull final Long userId, @Nonnull final Long notificationId, @Nonnull final UserNotificationDto userNotificationDto); @Nonnull @Override UserNotification getUserNotificationById(@Nonnull final Long userNotificationId); @Nonnull @Override List<UserNotification> getUserNotificationsByUserId(@Nonnull final Long userId); UserNotificationRepository getUserNotificationRepository(); void setUserNotificationRepository(final UserNotificationRepository userNotificationRepository); NotificationService getNotificationService(); void setNotificationService(final NotificationService notificationService); UserService getUserService(); void setUserService(final UserService userService);  }### Answer:
@Test public void testGetUserNotificationByIdWithInvalidArguments() { resetAll(); replayAll(); try { userNotificationService.getUserNotificationById(null); fail("Exception should be thrown"); } catch (final IllegalArgumentException ex) { } verifyAll(); }
@Test public void testGetUserNotificationByIdWithNotExistingNotificationId() { final Long userNotificationId = 1L; resetAll(); expect(userNotificationRepository.findById(eq(userNotificationId))).andReturn(Optional.empty()).once(); replayAll(); try { userNotificationService.getUserNotificationById(userNotificationId); fail("Exception should be thrown"); } catch (final UserNotificationNotFoundForIdException ex) { assertUserNotificationNotFoundForIdException(ex, userNotificationId); } verifyAll(); }
@Test public void testGetUserNotificationById() { final Long userNotificationId = 1L; final UserNotification userNotification = getServicesImplTestHelper().createUserNotification(); userNotification.setId(userNotificationId); resetAll(); expect(userNotificationRepository.findById(eq(userNotificationId))).andReturn(Optional.of(userNotification)).once(); replayAll(); final UserNotification result = userNotificationService.getUserNotificationById(userNotificationId); assertEquals(userNotification, result); verifyAll(); }