### Question:
ApnsProvider extends AbstractPushNotificationProvider implements NotificationProvider { @Override public void notifyCustomer(Notification notification) throws DispatchUnsupportedByUserException { Map<String, BaseEntity<?, ?>> additionaEntityParams = NotificationProviderUtil.addAdditionalParamsAndReturnRecipient(placeDao, personDao, accountDao, notification); Person recipient = NotificationProviderUtil.getPersonFromParams(additionaEntityParams); if (recipient == null) { throw new DispatchUnsupportedByUserException("No person found with id: " + notification.getPersonId()); } if (notification.getDeliveryEndpoint() != null) { String notificationMessage = messageRenderer.renderMessage(notification, NotificationMethod.APNS, recipient, additionaEntityParams); final String payload = generatePayload(notification, notificationMessage, additionaEntityParams); sendNotificationToDevice(notification, notification.getDeliveryEndpoint(), payload); } else { for (String thisToken : getDeviceTokensForPerson(notification.getPersonId(), MobileOS.IOS)) { retryProcessor.split(notification, NotificationMethod.APNS, thisToken); } } }  @Override void notifyCustomer(Notification notification);  }### Answer:
@Test(expected = DispatchUnsupportedByUserException.class) public void shouldThrowTerminalDispatchWithNoPerson() throws Exception { Mockito.when(personDao.findById(personId)).thenReturn(null); apnsProvider.notifyCustomer(notification); }
@Test(expected = DispatchUnsupportedByUserException.class) public void shouldThrowTerminalDispatchWithNullMobileDevices() throws Exception { Mockito.when(mobileDeviceDao.listForPerson(person)).thenReturn(null); apnsProvider.notifyCustomer(notification); }
@Test(expected = DispatchUnsupportedByUserException.class) public void shouldThrowTerminalDispatchWithNoMobileDevices() throws Exception { Mockito.when(mobileDeviceDao.listForPerson(person)).thenReturn(new ArrayList<MobileDevice>()); apnsProvider.notifyCustomer(notification); }
@Test public void shouldSendNotificationToMultipleDevices() throws Exception { apnsProvider.notifyCustomer(notification); Mockito.verify(retryProcessor).split(notification, NotificationMethod.APNS, iosToken1); Mockito.verify(retryProcessor).split(notification, NotificationMethod.APNS, iosToken2); }