4646import org .labkey .test .util .query .QueryApiHelper ;
4747
4848import java .util .ArrayList ;
49- import java .util .Arrays ;
5049import java .util .Collections ;
5150import java .util .Date ;
5251import java .util .List ;
@@ -67,6 +66,7 @@ public class ScriptValidationTest extends BaseWebDriverTest
6766 public static final String MODULE_NAME = "simpletest" ;
6867 public static final String VEHICLE_SCHEMA = "vehicle" ;
6968
69+ public static final String COLORS_TABLE = "colors" ;
7070 public static final String VEHICLES_TABLE = "vehicles" ;
7171
7272 public static class ColorRecord
@@ -103,7 +103,7 @@ protected void doSetup() throws Exception
103103 _containerHelper .createProject (getProjectName (), null );
104104 _containerHelper .enableModule (getProjectName (), MODULE_NAME );
105105 new QueryApiHelper (createDefaultConnection (), getProjectName (), VEHICLE_SCHEMA , VEHICLES_TABLE ).truncateTable ();
106- new QueryApiHelper (createDefaultConnection (), getProjectName (), VEHICLE_SCHEMA , "Colors" ).truncateTable ();
106+ new QueryApiHelper (createDefaultConnection (), getProjectName (), VEHICLE_SCHEMA , COLORS_TABLE ).truncateTable ();
107107 }
108108
109109 @ Test
@@ -127,9 +127,7 @@ public void doTestCrossFolderSaveRows() throws Exception
127127 {
128128 Connection cn = createDefaultConnection ();
129129
130- List <ColorRecord > colors = insertColors (Arrays .asList (
131- new ColorRecord ("Yellow2" , "#f00" )
132- ));
130+ List <ColorRecord > colors = insertColors (List .of (new ColorRecord ("Yellow2" , "#f00" )));
133131
134132 // Create manufacturers:
135133 ArrayList <Map <String , Object >> list1 = new ArrayList <>();
@@ -156,8 +154,8 @@ public void doTestCrossFolderSaveRows() throws Exception
156154 assertNotNull ("RowId not returned for vehicles insert, keys found: " + StringUtils .join (row .keySet (), "," ), vehicleRowId );
157155
158156 SelectRowsCommand src = new SelectRowsCommand (VEHICLE_SCHEMA , VEHICLES_TABLE );
159- src .setColumns (Arrays . asList ("Container" , "TriggerScriptContainer" , "RowId" , "ModelId" , "Milage" ));
160- src .setSorts (Arrays . asList (new Sort ("RowId" , Sort .Direction .DESCENDING )));
157+ src .setColumns (List . of ("Container" , "TriggerScriptContainer" , "RowId" , "ModelId" , "Milage" ));
158+ src .setSorts (List . of (new Sort ("RowId" , Sort .Direction .DESCENDING )));
161159 SelectRowsResponse sr2 = src .execute (cn , getProjectName ());
162160 assertEquals ("Incorrect model" , modelId , sr2 .getRows ().get (0 ).get ("ModelId" ));
163161 assertEquals ("Incorrect Milage" , 1234 , sr2 .getRows ().get (0 ).get ("Milage" ));
@@ -224,7 +222,7 @@ private PostCommand<CommandResponse> prepareSaveRowsCommand(String command, Stri
224222
225223 private void doTestTransformation () throws Exception
226224 {
227- List <ColorRecord > inserted = insertColors (Arrays . asList (
225+ List <ColorRecord > inserted = insertColors (List . of (
228226 new ColorRecord ("Yellow" , "#f00" ),
229227 new ColorRecord ("Cyan" , "#0f0" )
230228 ));
@@ -247,7 +245,7 @@ private void doTestValidation() throws Exception
247245 /* The following exception is logged to the server as it is meant to simulate an unexpected error in
248246 * script validation */
249247 log ("** Test errors: throw Error()'" );
250- insertColors (Arrays . asList (new ColorRecord ("ShouldError" , "not a hex value" )));
248+ insertColors (List . of (new ColorRecord ("ShouldError" , "not a hex value" )));
251249 fail ("Should throw an exception" );
252250 }
253251 catch (CommandException e )
@@ -259,7 +257,7 @@ private void doTestValidation() throws Exception
259257 try
260258 {
261259 log ("** Test errors: Field='message' and test extraContext is echoed back" );
262- insertColors (Arrays . asList (new ColorRecord ("TestFieldErrorMessage" , null )), Maps .of ("A" , "a" , "B" , 3 ));
260+ insertColors (List . of (new ColorRecord ("TestFieldErrorMessage" , null )), Maps .of ("A" , "a" , "B" , 3 ));
263261 fail ("Should throw an exception" );
264262 }
265263 catch (CommandException e )
@@ -298,7 +296,7 @@ private void doTestValidation() throws Exception
298296 try
299297 {
300298 log ("** Test errors: Field=[array of messages]" );
301- insertColors (Arrays . asList (new ColorRecord ("TestFieldErrorArray" , null )));
299+ insertColors (List . of (new ColorRecord ("TestFieldErrorArray" , null )));
302300 fail ("Should throw an exception" );
303301 }
304302 catch (CommandException e )
@@ -333,7 +331,7 @@ private void doTestValidation() throws Exception
333331 try
334332 {
335333 log ("** Test errors: row level error" );
336- insertColors (Arrays . asList (new ColorRecord ("TestRowError" , null )));
334+ insertColors (List . of (new ColorRecord ("TestRowError" , null )));
337335 fail ("Should throw an exception" );
338336 }
339337 catch (CommandException e )
@@ -366,7 +364,7 @@ private void doTestValidation() throws Exception
366364 try
367365 {
368366 log ("** Test errors: returning false" );
369- insertColors (Arrays . asList (new ColorRecord ("TestReturnFalse" , "" )));
367+ insertColors (List . of (new ColorRecord ("TestReturnFalse" , "" )));
370368 fail ("Should throw an exception" );
371369 }
372370 catch (CommandException e )
@@ -402,7 +400,7 @@ private void doTestValidation() throws Exception
402400 try
403401 {
404402 log ("** Test errors: error in complete" );
405- insertColors (Arrays . asList (
403+ insertColors (List . of (
406404 new ColorRecord ("Yellow" , "#f00" ),
407405 new ColorRecord ("Cyan" , "#0f0" ),
408406 new ColorRecord ("TestErrorInComplete" , "" )
@@ -438,7 +436,7 @@ private void doTestValidation() throws Exception
438436 try
439437 {
440438 log ("** Test errors: adding array of errors in complete" );
441- insertColors (Arrays . asList (new ColorRecord ("TestFieldErrorArrayInComplete" , "" )));
439+ insertColors (List . of (new ColorRecord ("TestFieldErrorArrayInComplete" , "" )));
442440 fail ("Should throw an exception" );
443441 }
444442 catch (CommandException e )
@@ -485,7 +483,7 @@ private void doTestValidation() throws Exception
485483 try
486484 {
487485 log ("** Test errors: script level variables, color regular expression" );
488- insertColors (Arrays . asList (new ColorRecord ("ShouldError" , "#still not a hex value" )));
486+ insertColors (List . of (new ColorRecord ("ShouldError" , "#still not a hex value" )));
489487 fail ("Should throw an exception" );
490488 }
491489 catch (CommandException e )
@@ -498,7 +496,7 @@ private void doTestValidation() throws Exception
498496 log ("** Test errors: updating hex value" );
499497 ColorRecord yellow = selectColor ("Yellow?" ).get (0 );
500498 yellow .hex = "shouldn't happen" ;
501- updateColors (Arrays . asList (yellow ));
499+ updateColors (List . of (yellow ));
502500 fail ("Should throw an exception" );
503501 }
504502 catch (CommandException e )
@@ -512,7 +510,7 @@ private List<ColorRecord> selectColor(String... names) throws Exception
512510 log ("** Selecting colors..." );
513511
514512 Connection cn = createDefaultConnection ();
515- SelectRowsCommand cmd = new SelectRowsCommand (VEHICLE_SCHEMA , "Colors" );
513+ SelectRowsCommand cmd = new SelectRowsCommand (VEHICLE_SCHEMA , COLORS_TABLE );
516514 cmd .addFilter ("Name" , StringUtils .join (names , ";" ), Filter .Operator .IN );
517515 SelectRowsResponse response = cmd .execute (cn , getProjectName ());
518516 assertEquals ("Expected to select " + names .length + " rows." , names .length , response .getRowCount ().intValue ());
@@ -536,7 +534,7 @@ private List<ColorRecord> insertColors(List<ColorRecord> colors, Map<String, Obj
536534
537535 log ("** Inserting colors..." );
538536 Connection cn = createDefaultConnection ();
539- InsertRowsCommand cmd = new InsertRowsCommand (VEHICLE_SCHEMA , "Colors" );
537+ InsertRowsCommand cmd = new InsertRowsCommand (VEHICLE_SCHEMA , COLORS_TABLE );
540538 cmd .getRows ().addAll (list );
541539 cmd .setExtraContext (extraContext );
542540 RowsResponse response = cmd .execute (cn , getProjectName ());
@@ -561,7 +559,7 @@ private List<ColorRecord> updateColors(List<ColorRecord> colors, Map<String, Obj
561559
562560 log ("** Updating colors..." );
563561 Connection cn = createDefaultConnection ();
564- UpdateRowsCommand cmd = new UpdateRowsCommand (VEHICLE_SCHEMA , "Colors" );
562+ UpdateRowsCommand cmd = new UpdateRowsCommand (VEHICLE_SCHEMA , COLORS_TABLE );
565563 cmd .getRows ().addAll (list );
566564 cmd .setExtraContext (extraContext );
567565 RowsResponse response = cmd .execute (cn , getProjectName ());
@@ -581,7 +579,7 @@ private List<ColorRecord> updateColors(List<ColorRecord> colors, Map<String, Obj
581579 @ Override
582580 public List <String > getAssociatedModules ()
583581 {
584- return Arrays . asList ( "simpletest" );
582+ return List . of ( MODULE_NAME );
585583 }
586584
587585 @ Override
0 commit comments