SolutionImportHandler implements IPlatformImportHandler { @VisibleForTesting boolean fileIsScheduleInputSource( ExportManifest manifest, String sourcePath ) { boolean isSchedulable = false; if ( sourcePath != null && manifest != null && manifest.getScheduleList() != null ) { String path = sourcePath.startsWith( "/" ) ? sourcePath : "/" + sourcePath; isSchedulable = manifest.getScheduleList().stream() .anyMatch( schedule -> path.equals( schedule.getInputFile() ) ); } if ( isSchedulable ) { getLogger().warn( Messages.getInstance() .getString( "ERROR.ScheduledWithoutPermission", sourcePath ) ); getLogger().warn( Messages.getInstance().getString( "SCHEDULE.AssigningPermission", sourcePath ) ); } return isSchedulable; } SolutionImportHandler( List<IMimeType> mimeTypes ); ImportSession getImportSession(); Log getLogger(); @Override void importFile( IPlatformImportBundle bundle ); @Override List<IMimeType> getMimeTypes(); IPlatformImportBundle build( RepositoryFileImportBundle.Builder builder ); Response createSchedulerJob( SchedulerResource scheduler, JobScheduleRequest jobScheduleRequest ); boolean isOverwriteFile(); void setOverwriteFile( boolean overwriteFile );  }
@Test public void testFileIsScheduleInputSource() { ExportManifest manifest = Mockito.mock( ExportManifest.class ); List<JobScheduleRequest> scheduleRequests = new ArrayList<>(); for ( int i = 0 ; i < 10; i++ ) { JobScheduleRequest jobScheduleRequest = new JobScheduleRequest(); jobScheduleRequest.setInputFile( "/public/test/file" + i ); scheduleRequests.add( jobScheduleRequest ); } Assert.assertFalse( importHandler.fileIsScheduleInputSource( manifest, null ) ); Mockito.when( manifest.getScheduleList() ).thenReturn( scheduleRequests ); Assert.assertFalse( importHandler.fileIsScheduleInputSource( manifest, "/public/file" ) ); Assert.assertTrue( importHandler.fileIsScheduleInputSource( manifest, "/public/test/file3" ) ); Assert.assertTrue( importHandler.fileIsScheduleInputSource( manifest, "public/test/file3" ) ); }