1717
1818import org .apache .commons .io .FileUtils ;
1919import org .junit .Assert ;
20- import org .junit .BeforeClass ;
2120import org .junit .Test ;
2221import org .junit .experimental .categories .Category ;
2322import org .labkey .remoteapi .CommandException ;
6059import java .io .IOException ;
6160import java .util .ArrayList ;
6261import java .util .Arrays ;
63- import java .util .Collections ;
62+ import java .util .Comparator ;
6463import java .util .HashMap ;
6564import java .util .List ;
6665import java .util .Map ;
@@ -141,17 +140,9 @@ protected boolean areDataListEqual(List<Map<String, String>> list01, List<Map<St
141140 return false ;
142141
143142 // Order the two lists so compare can be done by index and not by searching the two lists.
144- Collections .sort (list01 , (Map <String , String > o1 , Map <String , String > o2 )->
145- {
146- return o1 .get ("Name" ).compareTo (o2 .get ("Name" ));
147- }
148- );
143+ list01 .sort (Comparator .comparing ((Map <String , String > o ) -> o .get ("Name" )));
149144
150- Collections .sort (list02 , (Map <String , String > o1 , Map <String , String > o2 )->
151- {
152- return o1 .get ("Name" ).compareTo (o2 .get ("Name" ));
153- }
154- );
145+ list02 .sort (Comparator .comparing ((Map <String , String > o ) -> o .get ("Name" )));
155146
156147 boolean areEqual = true ;
157148
@@ -485,11 +476,12 @@ public void testExportImportDerivedSamples() throws Exception
485476 "ParentAlias" , "Parent3, Parent2" , "SelfParent" , "Child5" , "DataClassParent" , "data2, data3" ));
486477 testDgen .insertRows ();
487478
488- PortalHelper portalHelper = new PortalHelper (this );
489- portalHelper .addWebPart ("Sample Types" );
490- portalHelper .addWebPart ("Experiment Runs" );
479+ new PortalHelper (this ).doInAdminMode (portalHelper -> {
480+ portalHelper .addWebPart ("Sample Types" );
481+ portalHelper .addWebPart ("Experiment Runs" );
482+ });
491483
492- DataRegionTable sourceRunsTable = DataRegionTable .DataRegion (getDriver ()).withName ( " Runs" ).waitFor ();
484+ DataRegionTable sourceRunsTable = DataRegionTable .DataRegion (getDriver ()).inWebPart ( "Experiment Runs" ).waitFor ();
493485 List <String > runNames = sourceRunsTable .getColumnDataAsText ("Name" );
494486
495487 clickAndWait (Locator .linkWithText (testSamples ));
@@ -510,7 +502,7 @@ public void testExportImportDerivedSamples() throws Exception
510502 importFolderFromZip (exportedFolderFile , false , 1 );
511503 goToProjectFolder (IMPORT_PROJECT_NAME , importFolder );
512504
513- List <String > importedRunNames = DataRegionTable .DataRegion (getDriver ()).withName ( " Runs" ).waitFor ()
505+ List <String > importedRunNames = DataRegionTable .DataRegion (getDriver ()).inWebPart ( "Experiment Runs" ).waitFor ()
514506 .getColumnDataAsText ("Name" );
515507 for (String sourceRun : runNames )
516508 {
@@ -530,7 +522,7 @@ public void testExportImportDerivedSamples() throws Exception
530522 List <Map <String , String >> destRowData = destSamplesTable .getTableData ();
531523
532524 // now ensure expected data in the sampleType made it to the destination folder
533- for (Map exportedRow : sourceRowData )
525+ for (Map < String , String > exportedRow : sourceRowData )
534526 {
535527 // find the map from the exported project with the same name
536528 Map <String , String > matchingMap = destRowData .stream ().filter (a -> a .get ("Name" ).equals (exportedRow .get ("Name" )))
@@ -550,11 +542,11 @@ public void testExportImportDerivedSamples() throws Exception
550542 assertThat ("expect export and import values to be equivalent" ,
551543 exportedRow .get (decimalColFieldKey ), equalTo (matchingMap .get (decimalColFieldKey )));
552544
553- List <String > sourceParents = Arrays .asList (exportedRow .get ("Inputs/Materials/parentSamples" ). toString ()
545+ List <String > sourceParents = Arrays .asList (exportedRow .get ("Inputs/Materials/parentSamples" )
554546 .replace (" " , "" ).split ("," ));
555547 String [] importedParents = matchingMap .get ("Inputs/Materials/parentSamples" ).replace (" " , "" ).split ("," );
556548 assertThat ("expect parent sampleType derivation to round trip with equivalent values" , sourceParents , hasItems (importedParents ));
557- List <String > sourceDataParents = Arrays .asList (exportedRow .get ("Inputs/Data/parentDataClass" ). toString ()
549+ List <String > sourceDataParents = Arrays .asList (exportedRow .get ("Inputs/Data/parentDataClass" )
558550 .replace (" " , "" ).split ("," ));
559551 String [] importedDataParents = matchingMap .get ("Inputs/Data/parentDataClass" ).replace (" " , "" ).split ("," );
560552 assertThat ("expect parent dataClass derivation to round trip with equivalent values" , sourceDataParents , hasItems (importedDataParents ));
@@ -761,7 +753,7 @@ public void testExportImportSampleTypesWithAssayRuns() throws Exception
761753 importData .add (importedDataTable .getRowDataAsMap (i ));
762754 }
763755
764- for (Map exportedRow : exportData )
756+ for (Map < String , String > exportedRow : exportData )
765757 {
766758 // find the map from the exported project with the same name
767759 Map <String , String > matchingMap = importData .stream ().filter (a -> a .get ("sampleId" ).equals (exportedRow .get ("sampleId" )))
@@ -797,14 +789,14 @@ private FieldDefinition getFieldByNamePart(List<FieldDefinition> fields, String
797789 if (field .isNamePartMatch (namePart ))
798790 return field ;
799791 }
800- return null ;
792+ throw new RuntimeException ( "Field " + namePart + " not found: " + fields . stream (). map ( FieldDefinition :: getName ). toList ()) ;
801793 }
802794
803795 private StringBuilder checkDisplayFields (String displayField , List <String > columnLabels )
804796 {
805797 StringBuilder tmpString = new StringBuilder ();
806798
807- if (!columnLabels .contains ("Name" ))
799+ if (!columnLabels .contains (displayField ))
808800 {
809801 String errorMsg = "Did not find the 'Name' column." ;
810802 log ("\n *************** ERROR ***************\n " + errorMsg + "\n *************** ERROR ***************" );
0 commit comments