TargetsMngrImpl implements ITargetsMngr { List<TargetWrapperDescriptor> buildList( List<File> targetDirectories, AbstractApplication app ) { List<TargetWrapperDescriptor> result = new ArrayList<> (); for( File targetDirectory : targetDirectories ) { File associationFile = new File( targetDirectory, TARGETS_ASSOC_FILE ); Properties props = Utils.readPropertiesFileQuietly( associationFile, this.logger ); boolean isDefault = false; if( app != null ) isDefault = props.containsKey( new InstanceContext( app ).toString()); TargetWrapperDescriptor tb = build( targetDirectory ); if( tb != null ) { tb.setDefault( isDefault ); result.add( tb ); } } return result; } TargetsMngrImpl( IConfigurationMngr configurationMngr ); @Override String createTarget( String targetContent ); @Override String createTarget( File targetPropertiesFile, ApplicationTemplate creator ); @Override void updateTarget( String targetId, String newTargetContent ); @Override void deleteTarget( String targetId ); @Override void associateTargetWith( String targetId, AbstractApplication app, String instancePathOrComponentName ); @Override void dissociateTargetFrom( AbstractApplication app, String instancePathOrComponentName ); @Override void copyOriginalMapping( Application app ); @Override void applicationWasDeleted( AbstractApplication app ); @Override TargetProperties findTargetProperties( AbstractApplication app, String instancePath ); @Override TargetProperties findTargetProperties( String targetId ); @Override String findTargetId( AbstractApplication app, String instancePath, boolean strict ); @Override String findTargetId( AbstractApplication app, String instancePath ); @Override Map<String,byte[]> findScriptResourcesForAgent( String targetId ); @Override Map<String,byte[]> findScriptResourcesForAgent( AbstractApplication app, Instance scopedInstance ); @Override File findScriptForDm( AbstractApplication app, Instance scopedInstance ); @Override List<TargetWrapperDescriptor> listAllTargets(); @Override TargetWrapperDescriptor findTargetById( String targetId ); @Override List<TargetWrapperDescriptor> listPossibleTargets( AbstractApplication app ); @Override void addHint( String targetId, AbstractApplication app ); @Override void removeHint( String targetId, AbstractApplication app ); @Override TargetProperties lockAndGetTarget( Application app, Instance scopedInstance ); @Override void unlockTarget( Application app, Instance scopedInstance ); @Override List<TargetUsageItem> findUsageStatistics( String targetId );  }
@Test public void testBuildList_exception() throws Exception { File dir1 = this.folder.newFolder(); File dir2 = this.folder.newFolder(); Utils.writeStringInto( "prop: done", new File( dir1, Constants.TARGET_PROPERTIES_FILE_NAME )); List<File> targetDirectories = new ArrayList<>( 2 ); targetDirectories.add( dir1 ); targetDirectories.add( dir2 ); List<TargetWrapperDescriptor> beans = ((TargetsMngrImpl) this.mngr).buildList( targetDirectories, null ); Assert.assertEquals( 1, beans.size()); Assert.assertEquals( dir1.getName(), beans.get( 0 ).getId()); }