ApplicationMngrImpl implements IApplicationMngr { @Override public void updateApplication( ManagedApplication ma, String newDesc ) throws IOException { this.messagingMngr.checkMessagingConfiguration(); Application app = ma.getApplication(); app.setDescription( newDesc ); File targetDirectory = app.getDirectory(); File descFile = new File( targetDirectory, Constants.PROJECT_DIR_DESC + "/" + Constants.PROJECT_FILE_DESCRIPTOR ); Utils.createDirectory( descFile.getParentFile()); ApplicationDescriptor.save( descFile, app ); this.notificationMngr.application( ma.getApplication(), EventType.CHANGED ); this.logger.fine( "The description of application " + ma.getApplication().getName() + " was successfully updated." ); } 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 testUpdateApplication_success() throws Exception { TestApplication app = new TestApplication(); app.setDirectory( this.folder.newFolder()); ManagedApplication ma = new ManagedApplication( app ); TestManagerWrapper.addManagedApplication( this.mngr, ma ); String newDesc = "new description"; Assert.assertEquals( 0, app.getDirectory().listFiles().length ); Assert.assertFalse( newDesc.equals( app.getDescription())); this.mngr.updateApplication( ma, newDesc ); Assert.assertEquals( newDesc, app.getDescription()); Assert.assertEquals( 1, app.getDirectory().listFiles().length ); }
@Test( expected = IOException.class ) public void testUpdateApplication_saveFailure() throws Exception { TestApplication app = new TestApplication(); app.setDirectory( this.folder.newFile()); ManagedApplication ma = new ManagedApplication( app ); TestManagerWrapper.addManagedApplication( this.mngr, ma ); String newDesc = "new description"; this.mngr.updateApplication( ma, newDesc ); }