ApplicationTemplateMngrImpl implements IApplicationTemplateMngr { @Override public void deleteApplicationTemplate( String tplName, String tplVersion ) throws UnauthorizedActionException, InvalidApplicationException, IOException { ApplicationTemplate tpl = findTemplate( tplName, tplVersion ); if( tpl == null ) throw new InvalidApplicationException( new RoboconfError( ErrorCode.PROJ_APPLICATION_TEMPLATE_NOT_FOUND )); if( this.applicationMngr.isTemplateUsed( tpl )) { throw new UnauthorizedActionException( tplName + " (" + tplVersion + ") is still used by applications. It cannot be deleted." ); } else { this.logger.info( "Deleting the application template called " + tpl.getName() + "..." ); this.templates.remove( tpl ); this.notificationMngr.applicationTemplate( tpl, EventType.DELETED ); this.targetsMngr.applicationWasDeleted( tpl ); File targetDirectory = ConfigurationUtils.findTemplateDirectory( tpl, this.configurationMngr.getWorkingDirectory()); Utils.deleteFilesRecursively( targetDirectory ); this.logger.info( "Application template " + tpl.getName() + " was successfully deleted." ); } } ApplicationTemplateMngrImpl(
			INotificationMngr notificationMngr,
			ITargetsMngr targetsMngr,
			IApplicationMngr applicationMngr,
			IConfigurationMngr configurationMngr ); @Override Set<ApplicationTemplate> getApplicationTemplates(); @Override ApplicationTemplate findTemplate( String name, String version ); @Override ApplicationTemplate loadApplicationTemplate( File applicationFilesDirectory ); @Override void deleteApplicationTemplate( String tplName, String tplVersion ); @Override void restoreTemplates();  }
@Test( expected = InvalidApplicationException.class ) public void testDeleteApplicationTemplate_inexisting() throws Exception { this.mngr.deleteApplicationTemplate( "whatever", "version" ); }