### Question:
AbstractPushNotificationRecipientServiceImpl implements AbstractPushNotificationRecipientService<T> { @Transactional @Nonnull @Override public T updatePushNotificationRecipientStatus(@Nonnull final Long recipientId, @Nonnull final PushNotificationRecipientStatus status) { assertPushNotificationRecipientIdNotNull(recipientId); Assert.notNull(status, "Push notification recipient status should not be null"); LOGGER.debug("Updating push notification recipient status for recipient with id - {} , status - {}", recipientId, status); T recipient = getRepository().findById(recipientId).orElseThrow(() -> new PushNotificationRecipientNotFoundForIdException(recipientId, getInstanceClass()));; recipient.setStatus(status); recipient.setUpdated(LocalDateTime.now()); recipient = getRepository().save(recipient); LOGGER.debug("Successfully update push notification recipient status with id - {}, recipient - {}", recipient.getId(), recipient); return recipient; } AbstractPushNotificationRecipientServiceImpl(); @Nonnull @Override T getPushNotificationRecipientById(@Nonnull final Long recipientId); @Transactional @Nonnull @Override T updatePushNotificationRecipientUserDevice(@Nonnull final Long recipientId, @Nonnull final Long userDeviceId); @Transactional @Nonnull @Override T updatePushNotificationRecipientStatus(@Nonnull final Long recipientId, @Nonnull final PushNotificationRecipientStatus status); PushNotificationSubscriptionService getPushNotificationSubscriptionService(); void setPushNotificationSubscriptionService(final PushNotificationSubscriptionService pushNotificationSubscriptionService); PushNotificationRecipientRepository getPushNotificationRecipientRepository(); void setPushNotificationRecipientRepository(final PushNotificationRecipientRepository pushNotificationRecipientRepository); UserDeviceService getUserDeviceService(); void setUserDeviceService(final UserDeviceService userDeviceService); PushNotificationRecipientDeviceRepository getPushNotificationRecipientDeviceRepository(); void setPushNotificationRecipientDeviceRepository(final PushNotificationRecipientDeviceRepository pushNotificationRecipientDeviceRepository);  }### Answer:
@Test public void testUpdatePushNotificationRecipientStatusWithInvalidArguments() { final Long recipientId = 1L; final PushNotificationRecipientStatus status = PushNotificationRecipientStatus.DISABLED; resetAll(); replayAll(); try { getService().updatePushNotificationRecipientStatus(null, status); fail("Exception should be thrown"); } catch (final IllegalArgumentException ex) { } try { getService().updatePushNotificationRecipientStatus(recipientId, null); fail("Exception should be thrown"); } catch (final IllegalArgumentException ex) { } verifyAll(); }
@Test public void testUpdatePushNotificationRecipientStatus() { final Long recipientId = 1L; final T recipient = getInstance(); recipient.setStatus(PushNotificationRecipientStatus.ENABLED); final LocalDateTime recipientUpdateDate = recipient.getUpdated(); final PushNotificationRecipientStatus status = PushNotificationRecipientStatus.DISABLED; resetAll(); expect(getRepository().findById(eq(recipientId))).andReturn(Optional.of(recipient)).once(); expect(getRepository().save(isA(getInstanceClass()))).andAnswer(() -> (T) getCurrentArguments()[0]).once(); replayAll(); final T result = getService().updatePushNotificationRecipientStatus(recipientId, status); assertEquals(status, result.getStatus()); assertTrue(result.getUpdated().compareTo(recipientUpdateDate) >= 0 && recipientUpdateDate != result.getUpdated()); verifyAll(); }