BranchNotificationService { void scheduleMissingScreenshotNotificationsForBranch(Branch branch, String senderType) { Date date = DateTime.now().plusMinutes(30).toDate(); BranchNotificationMissingScreenshotsJobInput branchNotificationMissingScreenshotsJobInput = new BranchNotificationMissingScreenshotsJobInput(); branchNotificationMissingScreenshotsJobInput.setBranchId(branch.getId()); branchNotificationMissingScreenshotsJobInput.setSenderType(senderType); QuartzJobInfo quartzJobInfo = QuartzJobInfo.newBuilder(BranchNotificationMissingScreenshotsJob.class) .withInput(branchNotificationMissingScreenshotsJobInput) .withTriggerStartDate(date) .withUniqueId(senderType + "_" + branch.getId()) .build(); quartzPollableTaskScheduler.scheduleJob(quartzJobInfo); }  void sendNotificationsForBranch(Long branchId); void sendMissingScreenshotNotificationForBranch(Long branchId, String senderType);  }
@Test public void screenshotMissing() throws Exception { BranchTestData branchTestData = new BranchTestData(testIdWatcher); waitForCondition("Branch notification for branch1 is missing", () -> { return branchNotificationRepository.findByBranchAndSenderType(branchTestData.getBranch1(), senderType) != null; }); BranchNotification branchNotification = branchNotificationRepository.findByBranchAndSenderType(branchTestData.getBranch1(), senderType); branchNotification.setScreenshotMissingMsgSentAt(DateTime.now().minusMinutes(31)); branchNotificationRepository.save(branchNotification); branchNotificationService.scheduleMissingScreenshotNotificationsForBranch(branchTestData.getBranch1(), senderType); waitForCondition("Branch1 screenshot missing notification must be sent", () -> { return branchNotificationRepository.findByBranchAndSenderType(branchTestData.getBranch1(), senderType).getScreenshotMissingMsgSentAt() != null; }); }