3737import java .io .IOException ;
3838import java .util .ArrayList ;
3939import java .util .Arrays ;
40+ import java .util .Collections ;
4041import java .util .List ;
4142
4243import javax .script .ScriptEngine ;
@@ -64,10 +65,10 @@ public class ScriptFinderTest {
6465 public static void setUp () throws IOException {
6566 scriptsDir = TestUtils .createTemporaryDirectory ("script-finder-" );
6667 TestUtils .createPath (scriptsDir , "ignored.foo" );
67- TestUtils .createPath (scriptsDir , "Plugins /quick.foo" );
68- TestUtils .createPath (scriptsDir , "Plugins /brown.foo" );
69- TestUtils .createPath (scriptsDir , "Plugins /fox.foo" );
70- TestUtils .createPath (scriptsDir , "Plugins /The_Lazy_Dog.foo" );
68+ TestUtils .createPath (scriptsDir , "Scripts /quick.foo" );
69+ TestUtils .createPath (scriptsDir , "Scripts /brown.foo" );
70+ TestUtils .createPath (scriptsDir , "Scripts /fox.foo" );
71+ TestUtils .createPath (scriptsDir , "Scripts /The_Lazy_Dog.foo" );
7172 TestUtils .createPath (scriptsDir , "Math/add.foo" );
7273 TestUtils .createPath (scriptsDir , "Math/subtract.foo" );
7374 TestUtils .createPath (scriptsDir , "Math/multiply.foo" );
@@ -90,26 +91,32 @@ public void testFindScripts() {
9091 final ScriptService scriptService = context .service (ScriptService .class );
9192 scriptService .addScriptDirectory (scriptsDir );
9293
93- final ScriptFinder scriptFinder = new ScriptFinder (scriptService );
94+ final ArrayList < ScriptInfo > scripts = findScripts (scriptService );
9495
95- final ArrayList <ScriptInfo > scripts = new ArrayList <ScriptInfo >();
96- scriptFinder .findScripts (scripts );
9796 assertEquals (11 , scripts .size ());
98- assertMenuPath ("Math > add " , scripts , 0 );
99- assertMenuPath ("Math > divide " , scripts , 1 );
100- assertMenuPath ("Math > multiply " , scripts , 2 );
101- assertMenuPath ("Math > subtract " , scripts , 3 );
102- assertMenuPath ("Math > Trig > cos " , scripts , 4 );
103- assertMenuPath ("Math > Trig > sin " , scripts , 5 );
104- assertMenuPath ("Math > Trig > tan " , scripts , 6 );
105- assertMenuPath ("Plugins > brown " , scripts , 7 );
106- assertMenuPath ("Plugins > fox " , scripts , 8 );
107- assertMenuPath ("Plugins > quick " , scripts , 9 );
108- assertMenuPath ("Plugins > The Lazy Dog " , scripts , 10 );
97+ assertMenuPath ("Scripts > The Lazy Dog " , scripts , 0 );
98+ assertMenuPath ("Math > add " , scripts , 1 );
99+ assertMenuPath ("Scripts > brown " , scripts , 2 );
100+ assertMenuPath ("Math > Trig > cos " , scripts , 3 );
101+ assertMenuPath ("Math > divide " , scripts , 4 );
102+ assertMenuPath ("Scripts > fox " , scripts , 5 );
103+ assertMenuPath ("Math > multiply " , scripts , 6 );
104+ assertMenuPath ("Scripts > quick " , scripts , 7 );
105+ assertMenuPath ("Math > Trig > sin " , scripts , 8 );
106+ assertMenuPath ("Math > subtract " , scripts , 9 );
107+ assertMenuPath ("Math > Trig > tan " , scripts , 10 );
109108 }
110109
111110 // -- Helper methods --
112111
112+ private ArrayList <ScriptInfo > findScripts (final ScriptService scriptService ) {
113+ final ScriptFinder scriptFinder = new ScriptFinder (scriptService );
114+ final ArrayList <ScriptInfo > scripts = new ArrayList <ScriptInfo >();
115+ scriptFinder .findScripts (scripts );
116+ Collections .sort (scripts );
117+ return scripts ;
118+ }
119+
113120 private void assertMenuPath (final String menuString ,
114121 final ArrayList <ScriptInfo > scripts , final int i )
115122 {
0 commit comments