ApplicationMngrImpl implements IApplicationMngr { @Override public boolean isTemplateUsed( ApplicationTemplate tpl ) { boolean result = false; for( ManagedApplication ma : this.nameToManagedApplication.values()) { if( tpl.equals( ma.getApplication().getTemplate())) { result = true; break; } } return result; } ApplicationMngrImpl(
			INotificationMngr notificationMngr,
			IConfigurationMngr configurationMngr,
			ITargetsMngr targetsMngr,
			IMessagingMngr messagingMngr,
			IRandomMngr randomMngr,
			IAutonomicMngr autonomicMngr ); void setApplicationTemplateMngr( IApplicationTemplateMngr applicationTemplateMngr ); @Override Application findApplicationByName( String applicationName ); @Override ManagedApplication findManagedApplicationByName( String applicationName ); @Override Collection<ManagedApplication> getManagedApplications(); @Override ManagedApplication createApplication( String name, String description, String tplName, String tplQualifier ); @Override ManagedApplication createApplication( String name, String description, ApplicationTemplate tpl ); @Override void updateApplication( ManagedApplication ma, String newDesc ); @Override void deleteApplication( ManagedApplication ma ); @Override void restoreApplications(); @Override boolean isTemplateUsed( ApplicationTemplate tpl ); @Override void bindOrUnbindApplication( ManagedApplication ma, String externalExportPrefix, String applicationName, boolean bind ); @Override void replaceApplicationBindings( ManagedApplication ma, String externalExportPrefix, Set<String> applicationNames );  }
@Test public void testIsTemplateUsed() throws Exception { ApplicationTemplate tpl = new ApplicationTemplate( "lamp" ); Assert.assertFalse( this.mngr.isTemplateUsed( tpl )); ManagedApplication ma = new ManagedApplication( new Application( "app", tpl )); ma.getApplication().setDirectory( this.folder.newFolder()); TestManagerWrapper.addManagedApplication( this.mngr, ma ); Assert.assertTrue( this.mngr.isTemplateUsed( tpl )); ApplicationTemplate tpl2 = new ApplicationTemplate( "lamp" ).version( "v2" ); Assert.assertFalse( this.mngr.isTemplateUsed( tpl2 )); }