PentahoPlatformExporter extends ZipExportProcessor { protected void exportSchedules() { log.debug( "export schedules" ); try { List<Job> jobs = getScheduler().getJobs( null ); for ( Job job : jobs ) { if ( job.getJobName().equals( EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME ) ) { continue; } try { JobScheduleRequest scheduleRequest = ScheduleExportUtil.createJobScheduleRequest( job ); getExportManifest().addSchedule( scheduleRequest ); } catch ( IllegalArgumentException e ) { log.warn( e.getMessage(), e ); } } } catch ( SchedulerException e ) { log.error( Messages.getInstance().getString( "PentahoPlatformExporter.ERROR_EXPORTING_JOBS" ), e ); } } PentahoPlatformExporter( IUnifiedRepository repository ); File performExport(); @Override File performExport( RepositoryFile exportRepositoryFile ); IScheduler getScheduler(); void setScheduler( IScheduler scheduler ); IMetadataDomainRepository getMetadataDomainRepository(); void setMetadataDomainRepository( IMetadataDomainRepository metadataDomainRepository ); IDatasourceMgmtService getDatasourceMgmtService(); void setDatasourceMgmtService( IDatasourceMgmtService datasourceMgmtService ); MondrianCatalogRepositoryHelper getMondrianCatalogRepositoryHelper(); void setMondrianCatalogRepositoryHelper(
    MondrianCatalogRepositoryHelper mondrianCatalogRepositoryHelper ); IMondrianCatalogService getMondrianCatalogService(); void setMondrianCatalogService(
    IMondrianCatalogService mondrianCatalogService ); IUserSettingService getUserSettingService(); void setUserSettingService( IUserSettingService userSettingService ); static final String ROOT; static final String DATA_SOURCES_PATH_IN_ZIP; static final String METADATA_PATH_IN_ZIP; static final String ANALYSIS_PATH_IN_ZIP; static final String CONNECTIONS_PATH_IN_ZIP; static final String METASTORE; static final String METASTORE_BACKUP_EXT; }
@Test public void testExportSchedules() throws Exception { List<Job> jobs = new ArrayList<>(); ComplexJobTrigger trigger = mock( ComplexJobTrigger.class ); JobTrigger unknownTrigger = mock( JobTrigger.class ); Job job1 = mock( Job.class ); Job job2 = mock( Job.class ); Job job3 = mock( Job.class ); jobs.add( job1 ); jobs.add( job2 ); jobs.add( job3 ); when( scheduler.getJobs( null ) ).thenReturn( jobs ); when( job1.getJobName() ).thenReturn( EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME ); when( job2.getJobName() ).thenReturn( "job 2" ); when( job2.getJobTrigger() ).thenReturn( trigger ); when( job3.getJobName() ).thenReturn( "job 3" ); when( job3.getJobTrigger() ).thenReturn( unknownTrigger ); exporterSpy.exportSchedules(); verify( scheduler ).getJobs( null ); assertEquals( 1, exporterSpy.getExportManifest().getScheduleList().size() ); }
@Test public void testExportSchedules_SchedulereThrowsException() throws Exception { when( scheduler.getJobs( null ) ).thenThrow( new SchedulerException( "bad" ) ); exporterSpy.exportSchedules(); verify( scheduler ).getJobs( null ); assertEquals( 0, exporterSpy.getExportManifest().getScheduleList().size() ); }