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