33import org .apache .poi .ss .usermodel .Sheet ;
44import org .apache .poi .ss .usermodel .Workbook ;
55import org .jetbrains .annotations .Nullable ;
6+ import org .joda .time .DateTime ;
67import org .junit .AfterClass ;
78import org .junit .Before ;
89import org .junit .BeforeClass ;
3334
3435import java .io .File ;
3536import java .io .IOException ;
37+ import java .sql .Time ;
38+ import java .sql .Timestamp ;
3639import java .text .SimpleDateFormat ;
3740import java .util .ArrayList ;
3841import java .util .Arrays ;
4144import java .util .List ;
4245import java .util .Map ;
4346
47+ import static org .labkey .test .util .samplemanagement .SMTestUtils .COL_DATETIME_NAME ;
48+
4449@ Category ({Daily .class , Data .class , Hosting .class })
4550public class ListDateAndTimeTest extends BaseWebDriverTest
4651{
@@ -1022,8 +1027,6 @@ public void testInvalidDateAndTimeInsert()
10221027
10231028 log ("Validate adding entries in bulk will give a meaningful error with a bad format." );
10241029
1025- String expectedDateErrorMsgFormat = "'%s' is not a valid %s for %s using U.S. date parsing (MDY)" ;
1026- String expectedTimeErrorMsgFormat = "Could not convert value '%s' (String) for %s field '%s'" ;
10271030 String badDate = "45/93/2001" ;
10281031 String nonLeapDay = "2/29/2023" ;
10291032 String badTime = "26:abc:604" ;
@@ -1037,7 +1040,7 @@ public void testInvalidDateAndTimeInsert()
10371040
10381041 checker ().withScreenshot ()
10391042 .verifyEquals ("Error message for a bad date value not as expected." ,
1040- String . format ( expectedDateErrorMsgFormat , badDate , "Date" , dateCol ), actualErrorMsg );
1043+ getConversionErrorMessage ( badDate , dateCol , Date . class ), actualErrorMsg );
10411044
10421045 // Not a leap year.
10431046 bulkImportText = String .format ("%s\t \n %s" , dateCol , nonLeapDay );
@@ -1046,23 +1049,23 @@ public void testInvalidDateAndTimeInsert()
10461049
10471050 checker ().withScreenshot ()
10481051 .verifyEquals ("Error message for invalid leap day not as expected." ,
1049- String . format ( expectedDateErrorMsgFormat , nonLeapDay , "Date" , dateCol ), actualErrorMsg );
1052+ getConversionErrorMessage ( nonLeapDay , dateCol , Date . class ), actualErrorMsg );
10501053
10511054 bulkImportText = String .format ("%s\t \n %s" , timeCol , badTime );
10521055 importPage .setText (bulkImportText );
10531056 actualErrorMsg = importPage .submitExpectingError ();
10541057
10551058 checker ().withScreenshot ()
10561059 .verifyEquals ("Error message for a bad time value not as expected." ,
1057- String . format ( expectedTimeErrorMsgFormat , badTime , "Time" , timeCol ), actualErrorMsg );
1060+ getConversionErrorMessage ( badTime , timeCol , Time . class ), actualErrorMsg );
10581061
10591062 bulkImportText = String .format ("%s\t \n %s" , dateTimeCol , badDateTime );
10601063 importPage .setText (bulkImportText );
10611064 actualErrorMsg = importPage .submitExpectingError ();
10621065
10631066 checker ().withScreenshot ()
10641067 .verifyEquals ("Error message for a bad DateTime value not as expected." ,
1065- String . format ( expectedDateErrorMsgFormat , badDateTime , "Timestamp" , dateTimeCol ), actualErrorMsg );
1068+ getConversionErrorMessage ( badDateTime , dateTimeCol , Timestamp . class ), actualErrorMsg );
10661069
10671070 File excelDateTimeFile = TestFileUtils .getSampleData ("lists/Bad_Date_And_Time_Values.xlsx" );
10681071 importPage = importPage .selectUpload ();
@@ -1071,9 +1074,9 @@ public void testInvalidDateAndTimeInsert()
10711074
10721075 checker ().withScreenshot ()
10731076 .verifyTrue ("Error message for bad file import not as expected." ,
1074- actualErrorMsg .contains (String . format ( expectedTimeErrorMsgFormat , badTime , "Time" , timeCol )) &&
1075- actualErrorMsg .contains (String . format ( expectedDateErrorMsgFormat , nonLeapDay , "Date" , dateCol )) &&
1076- actualErrorMsg .contains (String . format ( expectedDateErrorMsgFormat , badDateTime , "Timestamp" , dateTimeCol ))
1077+ actualErrorMsg .contains (getConversionErrorMessage ( badTime , timeCol , Time . class )) &&
1078+ actualErrorMsg .contains (getConversionErrorMessage ( nonLeapDay , dateCol , Date . class )) &&
1079+ actualErrorMsg .contains (getConversionErrorMessage ( badDateTime , dateTimeCol , Timestamp . class ))
10771080 );
10781081
10791082 _listHelper .beginAtList (getProjectName (), listName );
0 commit comments