@Test public void testResumeDigestJobUpgradePluginFrom520To600() throws Exception { JobSchedulerService schedulerService = mock(JobSchedulerService.class); MailNotificationStorage mailNotificationStorage = mock(MailNotificationStorage.class); ResumeDigestJobUpgradePlugin plugin = new ResumeDigestJobUpgradePlugin(schedulerService, mailNotificationStorage, new InitParams()); plugin.processUpgrade("5.2.0", "6.0.0"); verify(mailNotificationStorage, times(1)).deleteAllDigests(); verify(mailNotificationStorage, times(1)).removeMessageAfterSent(Mockito.any()); verify(schedulerService,times(2)).resumeJob(anyString(),anyString()); }
@Override public void processUpgrade(String oldVersion, String newVersion) { try { if (VersionComparator.isAfter(oldVersion, "5.2.0") || VersionComparator.isSame(oldVersion, "5.2.0")) { mailNotificationStorage.deleteAllDigests(); NotificationContext context = NotificationContextImpl.cloneInstance(); mailNotificationStorage.removeMessageAfterSent(context); } schedulerService.resumeJob("NotificationDailyJob", "Notification"); schedulerService.resumeJob("NotificationWeeklyJob", "Notification"); } catch (Exception e) { LOG.error("Error when resuming daily and weekly job",e); throw new RuntimeException("An error occurred when resuming daily and weekly job"); } }
ResumeDigestJobUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { try { if (VersionComparator.isAfter(oldVersion, "5.2.0") || VersionComparator.isSame(oldVersion, "5.2.0")) { mailNotificationStorage.deleteAllDigests(); NotificationContext context = NotificationContextImpl.cloneInstance(); mailNotificationStorage.removeMessageAfterSent(context); } schedulerService.resumeJob("NotificationDailyJob", "Notification"); schedulerService.resumeJob("NotificationWeeklyJob", "Notification"); } catch (Exception e) { LOG.error("Error when resuming daily and weekly job",e); throw new RuntimeException("An error occurred when resuming daily and weekly job"); } } }
ResumeDigestJobUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { try { if (VersionComparator.isAfter(oldVersion, "5.2.0") || VersionComparator.isSame(oldVersion, "5.2.0")) { mailNotificationStorage.deleteAllDigests(); NotificationContext context = NotificationContextImpl.cloneInstance(); mailNotificationStorage.removeMessageAfterSent(context); } schedulerService.resumeJob("NotificationDailyJob", "Notification"); schedulerService.resumeJob("NotificationWeeklyJob", "Notification"); } catch (Exception e) { LOG.error("Error when resuming daily and weekly job",e); throw new RuntimeException("An error occurred when resuming daily and weekly job"); } } ResumeDigestJobUpgradePlugin(JobSchedulerService schedulerService, MailNotificationStorage mailNotificationStorage, InitParams initParams); }
ResumeDigestJobUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { try { if (VersionComparator.isAfter(oldVersion, "5.2.0") || VersionComparator.isSame(oldVersion, "5.2.0")) { mailNotificationStorage.deleteAllDigests(); NotificationContext context = NotificationContextImpl.cloneInstance(); mailNotificationStorage.removeMessageAfterSent(context); } schedulerService.resumeJob("NotificationDailyJob", "Notification"); schedulerService.resumeJob("NotificationWeeklyJob", "Notification"); } catch (Exception e) { LOG.error("Error when resuming daily and weekly job",e); throw new RuntimeException("An error occurred when resuming daily and weekly job"); } } ResumeDigestJobUpgradePlugin(JobSchedulerService schedulerService, MailNotificationStorage mailNotificationStorage, InitParams initParams); @Override void processUpgrade(String oldVersion, String newVersion); @Override boolean shouldProceedToUpgrade(String newVersion, String previousVersion); }
ResumeDigestJobUpgradePlugin extends UpgradeProductPlugin { @Override public void processUpgrade(String oldVersion, String newVersion) { try { if (VersionComparator.isAfter(oldVersion, "5.2.0") || VersionComparator.isSame(oldVersion, "5.2.0")) { mailNotificationStorage.deleteAllDigests(); NotificationContext context = NotificationContextImpl.cloneInstance(); mailNotificationStorage.removeMessageAfterSent(context); } schedulerService.resumeJob("NotificationDailyJob", "Notification"); schedulerService.resumeJob("NotificationWeeklyJob", "Notification"); } catch (Exception e) { LOG.error("Error when resuming daily and weekly job",e); throw new RuntimeException("An error occurred when resuming daily and weekly job"); } } ResumeDigestJobUpgradePlugin(JobSchedulerService schedulerService, MailNotificationStorage mailNotificationStorage, InitParams initParams); @Override void processUpgrade(String oldVersion, String newVersion); @Override boolean shouldProceedToUpgrade(String newVersion, String previousVersion);  }