### Question:
PushNotificationSubscriptionServiceImpl implements PushNotificationSubscriptionService { @Nonnull @Override public boolean checkIfPushNotificationSubscriptionExistsForUser(@Nonnull final Long userId) { assertUserIdNotNull(userId); LOGGER.debug("Checking if push notification subscription exists for user with id - {}", userId); final User user = userService.getUserById(userId); final PushNotificationSubscription subscription = pushNotificationSubscriptionRepository.findByUser(user); final boolean exists = (subscription != null); LOGGER.debug("Push notification subscription lookup result for user with id - {} is - {}", userId, exists); return exists; } 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 testCheckIfPushNotificationSubscriptionExistsForUserWithInvalidArguments() { resetAll(); replayAll(); try { pushNotificationSubscriptionService.checkIfPushNotificationSubscriptionExistsForUser(null); fail("Exception should be thrown"); } catch (final IllegalArgumentException ex) { } verifyAll(); }
@Test public void testCheckIfPushNotificationSubscriptionExistsForUserWhenItDoesNotExistYet() { final Long userId = 1L; final User user = getServicesImplTestHelper().createUser(); user.setId(userId); resetAll(); expect(userService.getUserById(eq(userId))).andReturn(user).once(); expect(pushNotificationSubscriptionRepository.findByUser(eq(user))).andReturn(null).once(); replayAll(); final boolean result = pushNotificationSubscriptionService.checkIfPushNotificationSubscriptionExistsForUser(userId); assertFalse(result); verifyAll(); }