@@ -66,18 +66,23 @@ public class ScriptFinderTest {
6666 @ BeforeClass
6767 public static void setUp () throws IOException {
6868 scriptsDir = TestUtils .createTemporaryDirectory ("script-finder-" );
69- TestUtils .createPath (scriptsDir , "ignored.foo" );
70- TestUtils .createPath (scriptsDir , "Scripts/quick.foo" );
71- TestUtils .createPath (scriptsDir , "Scripts/brown.foo" );
72- TestUtils .createPath (scriptsDir , "Scripts/fox.foo" );
73- TestUtils .createPath (scriptsDir , "Scripts/The_Lazy_Dog.foo" );
74- TestUtils .createPath (scriptsDir , "Math/add.foo" );
75- TestUtils .createPath (scriptsDir , "Math/subtract.foo" );
76- TestUtils .createPath (scriptsDir , "Math/multiply.foo" );
77- TestUtils .createPath (scriptsDir , "Math/divide.foo" );
78- TestUtils .createPath (scriptsDir , "Math/Trig/cos.foo" );
79- TestUtils .createPath (scriptsDir , "Math/Trig/sin.foo" );
80- TestUtils .createPath (scriptsDir , "Math/Trig/tan.foo" );
69+ final String [] scriptPaths = { //
70+ "ignored.foo" , //
71+ "Scripts/quick.foo" , //
72+ "Scripts/brown.foo" , //
73+ "Scripts/fox.foo" , //
74+ "Scripts/The_Lazy_Dog.foo" , //
75+ "Math/add.foo" , //
76+ "Math/subtract.foo" , //
77+ "Math/multiply.foo" , //
78+ "Math/divide.foo" , //
79+ "Math/Trig/cos.foo" , //
80+ "Math/Trig/sin.foo" , //
81+ "Math/Trig/tan.foo" , //
82+ };
83+ for (final String scriptPath : scriptPaths ) {
84+ TestUtils .createPath (scriptsDir , scriptPath );
85+ }
8186 }
8287
8388 @ AfterClass
@@ -94,18 +99,20 @@ public void testFindScripts() {
9499
95100 final ArrayList <ScriptInfo > scripts = findScripts (scriptService );
96101
97- assertEquals (11 , scripts .size ());
98- assertMenuPath ("Scripts > The Lazy Dog" , scripts , 0 );
99- assertMenuPath ("Math > add" , scripts , 1 );
100- assertMenuPath ("Scripts > brown" , scripts , 2 );
101- assertMenuPath ("Math > Trig > cos" , scripts , 3 );
102- assertMenuPath ("Math > divide" , scripts , 4 );
103- assertMenuPath ("Scripts > fox" , scripts , 5 );
104- assertMenuPath ("Math > multiply" , scripts , 6 );
105- assertMenuPath ("Scripts > quick" , scripts , 7 );
106- assertMenuPath ("Math > Trig > sin" , scripts , 8 );
107- assertMenuPath ("Math > subtract" , scripts , 9 );
108- assertMenuPath ("Math > Trig > tan" , scripts , 10 );
102+ final String [] expected = { //
103+ "Scripts > The Lazy Dog" , //
104+ "Math > add" , //
105+ "Scripts > brown" , //
106+ "Math > Trig > cos" , //
107+ "Math > divide" , //
108+ "Scripts > fox" , //
109+ "Math > multiply" , //
110+ "Scripts > quick" , //
111+ "Math > Trig > sin" , //
112+ "Math > subtract" , //
113+ "Math > Trig > tan" , //
114+ };
115+ assertMenuPaths (expected , scripts );
109116 }
110117
111118 /**
@@ -124,19 +131,21 @@ public void testMenuPrefixes() {
124131
125132 final ArrayList <ScriptInfo > scripts = findScripts (scriptService );
126133
127- assertEquals (12 , scripts .size ());
128- assertMenuPath ("Foo > Bar > Scripts > The Lazy Dog" , scripts , 0 );
129- assertMenuPath ("Foo > Bar > Math > add" , scripts , 1 );
130- assertMenuPath ("Foo > Bar > Scripts > brown" , scripts , 2 );
131- assertMenuPath ("Foo > Bar > Math > Trig > cos" , scripts , 3 );
132- assertMenuPath ("Foo > Bar > Math > divide" , scripts , 4 );
133- assertMenuPath ("Foo > Bar > Scripts > fox" , scripts , 5 );
134- assertMenuPath ("Foo > Bar > ignored" , scripts , 6 );
135- assertMenuPath ("Foo > Bar > Math > multiply" , scripts , 7 );
136- assertMenuPath ("Foo > Bar > Scripts > quick" , scripts , 8 );
137- assertMenuPath ("Foo > Bar > Math > Trig > sin" , scripts , 9 );
138- assertMenuPath ("Foo > Bar > Math > subtract" , scripts , 10 );
139- assertMenuPath ("Foo > Bar > Math > Trig > tan" , scripts , 11 );
134+ final String [] expected = { //
135+ "Foo > Bar > Scripts > The Lazy Dog" , //
136+ "Foo > Bar > Math > add" , //
137+ "Foo > Bar > Scripts > brown" , //
138+ "Foo > Bar > Math > Trig > cos" , //
139+ "Foo > Bar > Math > divide" , //
140+ "Foo > Bar > Scripts > fox" , //
141+ "Foo > Bar > ignored" , //
142+ "Foo > Bar > Math > multiply" , //
143+ "Foo > Bar > Scripts > quick" , //
144+ "Foo > Bar > Math > Trig > sin" , //
145+ "Foo > Bar > Math > subtract" , //
146+ "Foo > Bar > Math > Trig > tan" , //
147+ };
148+ assertMenuPaths (expected , scripts );
140149 }
141150
142151 /**
@@ -155,18 +164,20 @@ public void testOverlappingDirectories() {
155164
156165 final ArrayList <ScriptInfo > scripts = findScripts (scriptService );
157166
158- assertEquals (11 , scripts .size ());
159- assertMenuPath ("Plugins > The Lazy Dog" , scripts , 0 );
160- assertMenuPath ("Math > add" , scripts , 1 );
161- assertMenuPath ("Plugins > brown" , scripts , 2 );
162- assertMenuPath ("Math > Trig > cos" , scripts , 3 );
163- assertMenuPath ("Math > divide" , scripts , 4 );
164- assertMenuPath ("Plugins > fox" , scripts , 5 );
165- assertMenuPath ("Math > multiply" , scripts , 6 );
166- assertMenuPath ("Plugins > quick" , scripts , 7 );
167- assertMenuPath ("Math > Trig > sin" , scripts , 8 );
168- assertMenuPath ("Math > subtract" , scripts , 9 );
169- assertMenuPath ("Math > Trig > tan" , scripts , 10 );
167+ final String [] expected = { //
168+ "Plugins > The Lazy Dog" , //
169+ "Math > add" , //
170+ "Plugins > brown" , //
171+ "Math > Trig > cos" , //
172+ "Math > divide" , //
173+ "Plugins > fox" , //
174+ "Math > multiply" , //
175+ "Plugins > quick" , //
176+ "Math > Trig > sin" , //
177+ "Math > subtract" , //
178+ "Math > Trig > tan" , //
179+ };
180+ assertMenuPaths (expected , scripts );
170181 }
171182
172183 // -- Helper methods --
@@ -188,10 +199,14 @@ private ArrayList<ScriptInfo> findScripts(final ScriptService scriptService) {
188199 return scripts ;
189200 }
190201
191- private void assertMenuPath (final String menuString ,
192- final ArrayList <ScriptInfo > scripts , final int i )
202+ private void assertMenuPaths (final String [] expected ,
203+ final ArrayList <ScriptInfo > scripts )
193204 {
194- assertEquals (menuString , scripts .get (i ).getMenuPath ().getMenuString ());
205+ assertEquals (expected .length , scripts .size ());
206+ for (int i =0 ; i <expected .length ; i ++) {
207+ final String actual = scripts .get (i ).getMenuPath ().getMenuString ();
208+ assertEquals (expected [i ], actual );
209+ }
195210 }
196211
197212 // -- Helper classes --
0 commit comments