### Question:
PushNotificationSubscriptionServiceImpl implements PushNotificationSubscriptionService { @Nonnull @Override public PushNotificationSubscription getPushNotificationSubscriptionById(@Nonnull final Long subscriptionId) { assertPushNotificationSubscriptionId(subscriptionId); LOGGER.debug("Getting push notification subscription for id - {}", subscriptionId); final PushNotificationSubscription subscription = pushNotificationSubscriptionRepository.findById(subscriptionId) .orElseThrow(() -> new PushNotificationSubscriptionNotFoundForIdException(subscriptionId)); LOGGER.debug("Successfully retrieved push notification subscription for id - {}, subscription - {}", subscription.getId(), subscription); return subscription; } PushNotificationSubscriptionServiceImpl(); @Nonnull @Override boolean checkIfPushNotificationSubscriptionExistsForUser(@Nonnull final Long userId); @Nonnull @Override PushNotificationSubscription getPushNotificationSubscriptionForUser(@Nonnull final Long userId); @Transactional @Nonnull @Override PushNotificationSubscription createPushNotificationSubscription(@Nonnull final Long userId, @Nonnull final PushNotificationSubscriptionDto subscriptionDto); @Nonnull @Override PushNotificationSubscription getPushNotificationSubscriptionById(@Nonnull final Long subscriptionId); PushNotificationSubscriptionRepository getPushNotificationSubscriptionRepository(); void setPushNotificationSubscriptionRepository(final PushNotificationSubscriptionRepository pushNotificationSubscriptionRepository); UserService getUserService(); void setUserService(final UserService userService);  }### Answer:
@Test public void testGetPushNotificationSubscriptionByIdWithInvalidArguments() { resetAll(); replayAll(); try { pushNotificationSubscriptionService.getPushNotificationSubscriptionById(null); fail("Exception should be thrown"); } catch (final IllegalArgumentException ex) { } verifyAll(); }
@Test public void testGetPushNotificationSubscriptionByIdWithNotExistingId() { final Long subscriptionId = 1L; resetAll(); expect(pushNotificationSubscriptionRepository.findById(eq(subscriptionId))).andReturn(Optional.empty()).once(); replayAll(); try { pushNotificationSubscriptionService.getPushNotificationSubscriptionById(subscriptionId); fail("Exception should be thrown"); } catch (final PushNotificationSubscriptionNotFoundForIdException ex) { assertPushNotificationSubscriptionNotFoundForIdException(ex, subscriptionId); } verifyAll(); }
@Test public void testGetPushNotificationSubscriptionById() { final Long subscriptionId = 1L; final PushNotificationSubscription subscription = getServicesImplTestHelper().createPushNotificationSubscription(); subscription.setId(subscriptionId); resetAll(); expect(pushNotificationSubscriptionRepository.findById(eq(subscriptionId))).andReturn(Optional.of(subscription)).once(); replayAll(); final PushNotificationSubscription result = pushNotificationSubscriptionService.getPushNotificationSubscriptionById(subscriptionId); assertEquals(subscription, result); verifyAll(); }