@@ -435,6 +435,9 @@ public void testExportImportDerivedSamples() throws Exception
435435
436436 // arrange - 2 sample types, one with samples derived from parents in the other (and also parents in the same one)
437437 List <FieldDefinition > testFields = SampleTypeAPIHelper .sampleTypeTestFields (false );
438+ FieldDefinition intColumn = getFieldByNamePart (testFields , "intColumn" );
439+ FieldDefinition stringColumn = getFieldByNamePart (testFields , "stringColumn" );
440+ FieldDefinition decimalColumn = getFieldByNamePart (testFields , "decimalColumn" );
438441 DataClassDefinition dataClassType = new DataClassDefinition (dataClass ).setFields (DataClassAPIHelper .dataClassTestFields ());
439442 SampleTypeDefinition parentType = new SampleTypeDefinition (parentSampleType ).setFields (testFields );
440443 SampleTypeDefinition testSampleType = new SampleTypeDefinition (testSamples ).setFields (testFields )
@@ -449,25 +452,25 @@ public void testExportImportDerivedSamples() throws Exception
449452 dataClassDgen .insertRows ();
450453
451454 TestDataGenerator parentDgen = SampleTypeAPIHelper .createEmptySampleType (subfolderPath , parentType );
452- parentDgen .addCustomRow (Map .of ("Name" , "Parent1" , " intColumn" , 1 , "floatColumn" , 1.1 , " stringColumn" , "one" ));
453- parentDgen .addCustomRow (Map .of ("Name" , "Parent2" , " intColumn" , 2 , "floatColumn" , 2.2 , " stringColumn" , "two" ));
454- parentDgen .addCustomRow (Map .of ("Name" , "Parent3" , " intColumn" , 3 , "floatColumn" , 3.3 , " stringColumn" , "three" ));
455+ parentDgen .addCustomRow (Map .of ("Name" , "Parent1" , intColumn . getName () , 1 , decimalColumn . getName () , 1.1 , stringColumn . getName () , "one" ));
456+ parentDgen .addCustomRow (Map .of ("Name" , "Parent2" , intColumn . getName () , 2 , decimalColumn . getName () , 2.2 , stringColumn . getName () , "two" ));
457+ parentDgen .addCustomRow (Map .of ("Name" , "Parent3" , intColumn . getName () , 3 , decimalColumn . getName () , 3.3 , stringColumn . getName () , "three" ));
455458 parentDgen .insertRows ();
456459
457460 TestDataGenerator testDgen = SampleTypeAPIHelper .createEmptySampleType (subfolderPath , testSampleType );
458- testDgen .addCustomRow (Map .of ("Name" , "Child1" , " intColumn" , 1 , " decimalColumn" , 1.1 , " stringColumn" , "one" ,
461+ testDgen .addCustomRow (Map .of ("Name" , "Child1" , intColumn . getName () , 1 , decimalColumn . getName () , 1.1 , stringColumn . getName () , "one" ,
459462 "Parent" , "Parent1" ));
460- testDgen .addCustomRow (Map .of ("Name" , "Child2" , " intColumn" , 2 , " decimalColumn" , 2.2 , " stringColumn" , "two" ,
463+ testDgen .addCustomRow (Map .of ("Name" , "Child2" , intColumn . getName () , 2 , decimalColumn . getName () , 2.2 , stringColumn . getName () , "two" ,
461464 "Parent" , "Parent2" ));
462- testDgen .addCustomRow (Map .of ("Name" , "Child3" , " intColumn" , 3 , " decimalColumn" , 3.3 , " stringColumn" , "three" ,
465+ testDgen .addCustomRow (Map .of ("Name" , "Child3" , intColumn . getName () , 3 , decimalColumn . getName () , 3.3 , stringColumn . getName () , "three" ,
463466 "Parent" , "Parent3" , "DataClassParent" , "data1" ));
464- testDgen .addCustomRow (Map .of ("Name" , "Child4" , " intColumn" , 4 , " decimalColumn" , 4.4 , " stringColumn" , "four" ,
467+ testDgen .addCustomRow (Map .of ("Name" , "Child4" , intColumn . getName () , 4 , decimalColumn . getName () , 4.4 , stringColumn . getName () , "four" ,
465468 "Parent" , "Parent3, Parent2" ));
466- testDgen .addCustomRow (Map .of ("Name" , "Child5" , " intColumn" , 5 , " decimalColumn" , 5.5 , " stringColumn" , "five" ,
469+ testDgen .addCustomRow (Map .of ("Name" , "Child5" , intColumn . getName () , 5 , decimalColumn . getName () , 5.5 , stringColumn . getName () , "five" ,
467470 "Parent" , "Parent1, Parent2" ));
468- testDgen .addCustomRow (Map .of ("Name" , "Child6" , " intColumn" , 6 , " decimalColumn" , 6.6 , " stringColumn" , "six" ,
471+ testDgen .addCustomRow (Map .of ("Name" , "Child6" , intColumn . getName () , 6 , decimalColumn . getName () , 6.6 , stringColumn . getName () , "six" ,
469472 "Parent" , "Parent3, Parent2" , "SelfParent" , "Child5" ));
470- testDgen .addCustomRow (Map .of ("Name" , "Child7" , " intColumn" , 7 , " decimalColumn" , 7.7 , " stringColumn" , "seven" ,
473+ testDgen .addCustomRow (Map .of ("Name" , "Child7" , intColumn . getName () , 7 , decimalColumn . getName () , 7.7 , stringColumn . getName () , "seven" ,
471474 "Parent" , "Parent3, Parent2" , "SelfParent" , "Child5" , "DataClassParent" , "data2, data3" ));
472475 testDgen .insertRows ();
473476
@@ -556,13 +559,16 @@ public void testExportImportSampleTypesWithAssayRuns() throws Exception
556559
557560 // create a test sampleType
558561 List <FieldDefinition > testFields = SampleTypeAPIHelper .sampleTypeTestFields (true );
562+ FieldDefinition intColumn = getFieldByNamePart (testFields , "intColumn" );
563+ FieldDefinition stringColumn = getFieldByNamePart (testFields , "stringColumn" );
564+ FieldDefinition decimalColumn = getFieldByNamePart (testFields , "decimalColumn" );
559565 SampleTypeDefinition testSampleType = new SampleTypeDefinition (testSamples ).setFields (testFields )
560566 .addParentAlias ("SelfParent" ); // to derive from samles in the current type
561567
562568 TestDataGenerator parentDgen = SampleTypeAPIHelper .createEmptySampleType (subfolderPath , testSampleType );
563- parentDgen .addCustomRow (Map .of ("Name" , "sample1" , " intColumn" , 1 , " decimalColumn" , 1.1 , " stringColumn" , "one" ));
564- parentDgen .addCustomRow (Map .of ("Name" , "sample2" , " intColumn" , 2 , " decimalColumn" , 2.2 , " stringColumn" , "two" ));
565- parentDgen .addCustomRow (Map .of ("Name" , "sample3" , " intColumn" , 3 , " decimalColumn" , 3.3 , " stringColumn" , "three" ));
569+ parentDgen .addCustomRow (Map .of ("Name" , "sample1" , intColumn . getName () , 1 , decimalColumn . getName () , 1.1 , stringColumn . getName () , "one" ));
570+ parentDgen .addCustomRow (Map .of ("Name" , "sample2" , intColumn . getName () , 2 , decimalColumn . getName () , 2.2 , stringColumn . getName () , "two" ));
571+ parentDgen .addCustomRow (Map .of ("Name" , "sample3" , intColumn . getName () , 3 , decimalColumn . getName () , 3.3 , stringColumn . getName () , "three" ));
566572 parentDgen .insertRows ();
567573
568574 goToProjectFolder (getProjectName (), subfolder );
@@ -685,8 +691,28 @@ public void testExportImportSampleTypesWithAssayRuns() throws Exception
685691 File downloadedFile = doAndWaitForDownload (() -> waitAndClick (WAIT_FOR_JAVASCRIPT , Locator .tagWithAttribute ("a" , "title" , "Download attached file" ), 0 ));
686692 assertElementPresent ("Did not find the expected number of icons for " + SAMPLE_TXT_FILE .getName () + " from the imported samples." , Locator .tagContainingText ("a" , "sample.txt" ), 1 );
687693 checker ().verifyTrue ("Incorrect file content for sample.txt after folder import" , FileUtils .contentEquals (downloadedFile , SAMPLE_TXT_FILE ));
694+
695+ // verify the other sample type data is round-tripped as expected
696+ importedDataTable = DataRegionTable .DataRegion (getDriver ()).withName ("Material" ).waitFor ();
697+ checker ().verifyEquals ("Name column data not as expected" , List .of ("sample3" , "sample2" , "sample1" ),
698+ importedDataTable .getColumnDataAsText ("Name" ));
699+ checker ().verifyEquals ("intColumn column data not as expected" , List .of ("3" , "2" , "1" ),
700+ importedDataTable .getColumnDataAsText (intColumn .getName ()));
701+ checker ().verifyEquals ("decimalColumn column data not as expected" , List .of ("3.3" , "2.2" , "1.1" ),
702+ importedDataTable .getColumnDataAsText (decimalColumn .getName ()));
703+ checker ().verifyEquals ("stringColumn column data not as expected" , List .of ("three" , "two" , "one" ),
704+ importedDataTable .getColumnDataAsText (stringColumn .getName ()));
688705 }
689706
707+ private FieldDefinition getFieldByNamePart (List <FieldDefinition > fields , String namePart )
708+ {
709+ for (FieldDefinition field : fields )
710+ {
711+ if (field .isNamePartMatch (namePart ))
712+ return field ;
713+ }
714+ return null ;
715+ }
690716
691717 private StringBuilder checkDisplayFields (String displayField , List <String > columnLabels )
692718 {
0 commit comments