PendingRoleMembershipApprovalNotificationTask implements NotificationTask { @Override public List<Notification> getNotifications() { dbService.processExpiredPendingMembers(pendingRoleMemberLifespan, monitorIdentity); Set<String> recipients = dbService.getPendingMembershipApproverRoles(1); return Collections.singletonList(notificationCommon.createNotification( recipients, null, pendingMembershipApprovalNotificationToEmailConverter, NOTIFICATION_TYPE)); } PendingRoleMembershipApprovalNotificationTask(DBService dbService, int pendingRoleMemberLifespan, String monitorIdentity, String userDomainPrefix); @Override List<Notification> getNotifications(); @Override String getDescription();  }
@Test public void testSendPendingMembershipApprovalReminders() { DBService dbsvc = Mockito.mock(DBService.class); NotificationService mockNotificationService = Mockito.mock(NotificationService.class); NotificationServiceFactory testfact = () -> mockNotificationService; Mockito.when(dbsvc.getPendingMembershipApproverRoles(1)) .thenReturn(null) .thenReturn(Collections.singleton("user.joe")); NotificationManager notificationManager = getNotificationManager(dbsvc, testfact); ZMSTestUtils.sleep(1000); PendingRoleMembershipApprovalNotificationTask reminder = new PendingRoleMembershipApprovalNotificationTask(dbsvc, 0, "", USER_DOMAIN_PREFIX); List<Notification> notifications = reminder.getNotifications(); assertEquals(notifications.size(), 1); Notification expectedNotification = new Notification(); expectedNotification.setNotificationToEmailConverter(new PendingRoleMembershipApprovalNotificationTask.PendingRoleMembershipApprovalNotificationToEmailConverter()); expectedNotification.addRecipient("user.joe"); expectedNotification.setType("pending_role_membership_approval"); assertEquals(notifications.get(0), expectedNotification); notificationManager.shutdown(); }