CommandsMngrImpl implements ICommandsMngr { @Override public List<String> listCommands( Application app ) { List<String> result = new ArrayList<> (); File cmdDir = new File( app.getDirectory(), Constants.PROJECT_DIR_COMMANDS ); if( cmdDir.isDirectory()) { for( File f : Utils.listAllFiles( cmdDir )) { if( f.getName().endsWith( Constants.FILE_EXT_COMMANDS )) { String cmdName = f.getName().replace( Constants.FILE_EXT_COMMANDS, "" ); result.add( cmdName ); } } } return result; } CommandsMngrImpl( Manager manager ); @Override void createOrUpdateCommand( Application app, String commandName, String commandText ); @Override void deleteCommand( Application app, String commandName ); @Override List<String> listCommands( Application app ); @Override String getCommandInstructions( Application app, String commandName ); @Override List<ParsingError> validate( Application app, String commandText ); @Override int getHistoryNumberOfPages( int itemsPerPage, String applicationName ); @Override List<CommandHistoryItem> getHistory(
			int start,
			int maxEntry,
			String sortCriteria,
			String sortingOrder,
			String applicationName ); @Override void execute( Application app, String commandName, int origin, String originDetails ); @Override void execute(
			Application app,
			String commandName,
			CommandExecutionContext executionContext,
			int origin,
			String originDetails );  }
@Test public void testListCommands() throws Exception { Application inexisting = new Application( "inexisting", this.app.getTemplate()); Assert.assertEquals( 0, this.cmdMngr.listCommands( inexisting ).size()); Assert.assertEquals( 0, this.cmdMngr.listCommands( this.app ).size()); this.cmdMngr.createOrUpdateCommand( this.app, "toto", "Good command"); List<String> list = this.cmdMngr.listCommands( this.app ); Assert.assertEquals( 1, list.size()); Assert.assertEquals( "toto", list.get( 0 )); this.cmdMngr.createOrUpdateCommand( this.app, "before", "Good command"); this.cmdMngr.createOrUpdateCommand( this.app, "toto2", "Good command"); list = this.cmdMngr.listCommands( this.app ); Assert.assertEquals( 3, list.size()); Assert.assertEquals( "before", list.get( 0 )); Assert.assertEquals( "toto", list.get( 1 )); Assert.assertEquals( "toto2", list.get( 2 )); this.cmdMngr.deleteCommand( this.app, "toto" ); list = this.cmdMngr.listCommands( this.app ); Assert.assertEquals( 2, list.size()); Assert.assertEquals( "before", list.get( 0 )); Assert.assertEquals( "toto2", list.get( 1 )); }