### Question:
PushNotificationServiceImpl extends AbstractNotificationServiceImpl<PushNotification> implements PushNotificationService { @Transactional @Nonnull @Override public PushNotification createNotification(@Nonnull final Long pushNotificationRecipientId, @Nonnull final PushNotificationDto pushNotificationDto) { Assert.notNull(pushNotificationRecipientId, "Push notification recipient id should not be null"); assertPushNotificationDto(pushNotificationDto); logger.debug("Creating push notification for recipient with id - {}, DTO - {}, properties - {}", pushNotificationRecipientId, pushNotificationDto, pushNotificationDto.getProperties()); final PushNotificationRecipient recipient = pushNotificationRecipientService.getPushNotificationRecipientById(pushNotificationRecipientId); PushNotification pushNotification = new PushNotification(true); pushNotificationDto.updateDomainEntityProperties(pushNotification); pushNotification.setRecipient(recipient); pushNotification.setProviderType(recipient.getType().getNotificationProviderType()); pushNotification.setLocale(pushNotificationDto.getLocale()); pushNotification.setTemplateName(pushNotificationDto.getTemplateName()); pushNotification = pushNotificationRepository.save(pushNotification); logger.debug("Successfully created push notification with id - {}, push notification - {}", pushNotification.getId(), pushNotification); return pushNotification; } PushNotificationServiceImpl(); @Transactional @Nonnull @Override PushNotification createNotification(@Nonnull final Long pushNotificationRecipientId, @Nonnull final PushNotificationDto pushNotificationDto); @Transactional @Nonnull @Override List<PushNotification> createNotificationsForUserActiveRecipients(@Nonnull final Long userId, @Nonnull final PushNotificationDto pushNotificationDto); @Override @Transactional(readOnly = true) PushNotification getPushNotificationForProcessing(final Long notificationId); PushNotificationRepository getPushNotificationRepository(); void setPushNotificationRepository(final PushNotificationRepository pushNotificationRepository); PushNotificationRecipientService getPushNotificationRecipientService(); void setPushNotificationRecipientService(final PushNotificationRecipientService pushNotificationRecipientService); UserService getUserService(); void setUserService(final UserService userService); PushNotificationSubscriptionService getPushNotificationSubscriptionService(); void setPushNotificationSubscriptionService(final PushNotificationSubscriptionService pushNotificationSubscriptionService); UserNotificationService getUserNotificationService(); void setUserNotificationService(final UserNotificationService userNotificationService);  }### Answer:
@Test public void testCreateNotificationWithInvalidArguments() { final Long recipientId = 1L; final PushNotificationDto notificationDto = getServicesImplTestHelper().createPushNotificationDto(); resetAll(); replayAll(); try { pushNotificationService.createNotification(null, notificationDto); fail("Exception should be thrown"); } catch (final IllegalArgumentException ex) { } try { pushNotificationService.createNotification(recipientId, null); fail("Exception should be thrown"); } catch (final IllegalArgumentException ex) { } verifyAll(); }
@Test public void testCreateNotification() { final Long recipientId = 1L; final PushNotificationRecipient recipient = getServicesImplTestHelper().createPushNotificationSnsRecipient(); recipient.setId(recipientId); final PushNotificationDto notificationDto = getServicesImplTestHelper().createPushNotificationDto(); notificationDto.setProperties(getServicesImplTestHelper().createNotificationProperties(10)); resetAll(); expect(pushNotificationRecipientService.getPushNotificationRecipientById(eq(recipientId))).andReturn(recipient).once(); expect(pushNotificationRepository.save(isA(PushNotification.class))).andAnswer(() -> (PushNotification) getCurrentArguments()[0]).once(); replayAll(); final PushNotification result = pushNotificationService.createNotification(recipientId, notificationDto); getServicesImplTestHelper().assertPushNotification(result, notificationDto); assertEquals(recipient, result.getRecipient()); assertEquals(notificationDto.getProperties().size(), result.getProperties().size()); final MutableInt counter = new MutableInt(0); assertEquals(result.getProperties().stream().collect(Collectors.toMap(NotificationProperty::getPropertyKey, NotificationProperty::getPropertyValue)), notificationDto.getProperties()); verifyAll(); }