Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/org/labkey/test/tests/SampleTypeLineageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -311,7 +312,7 @@ at ParentFolder_SampleType in the sub folder it should see one sample (the deriv

log("Again check that data validation works as expected.");
checker().verifyTrue("Expected error message 'is not a valid Date' is not present.",
isTextPresent("'BadDate' is not a valid Date for DateCol "));
isTextPresent(getConversionErrorMessage("BadDate", "DateCol", Date.class)));
setFormElement(Locator.name("Output Sample 1_DateCol"), "1/1/2007");
clickButton("Submit");

Expand Down
21 changes: 12 additions & 9 deletions src/org/labkey/test/tests/list/ListDateAndTimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.jetbrains.annotations.Nullable;
import org.joda.time.DateTime;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -33,6 +34,8 @@

import java.io.File;
import java.io.IOException;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -41,6 +44,8 @@
import java.util.List;
import java.util.Map;

import static org.labkey.test.util.samplemanagement.SMTestUtils.COL_DATETIME_NAME;

@Category({Daily.class, Data.class, Hosting.class})
public class ListDateAndTimeTest extends BaseWebDriverTest
{
Expand Down Expand Up @@ -1022,8 +1027,6 @@ public void testInvalidDateAndTimeInsert()

log("Validate adding entries in bulk will give a meaningful error with a bad format.");

String expectedDateErrorMsgFormat = "'%s' is not a valid %s for %s using U.S. date parsing (MDY)";
String expectedTimeErrorMsgFormat = "Could not convert value '%s' (String) for %s field '%s'";
String badDate = "45/93/2001";
String nonLeapDay = "2/29/2023";
String badTime = "26:abc:604";
Expand All @@ -1037,7 +1040,7 @@ public void testInvalidDateAndTimeInsert()

checker().withScreenshot()
.verifyEquals("Error message for a bad date value not as expected.",
String.format(expectedDateErrorMsgFormat, badDate, "Date", dateCol), actualErrorMsg);
getConversionErrorMessage(badDate, dateCol, Date.class), actualErrorMsg);

// Not a leap year.
bulkImportText = String.format("%s\t\n%s", dateCol, nonLeapDay);
Expand All @@ -1046,23 +1049,23 @@ public void testInvalidDateAndTimeInsert()

checker().withScreenshot()
.verifyEquals("Error message for invalid leap day not as expected.",
String.format(expectedDateErrorMsgFormat, nonLeapDay, "Date", dateCol), actualErrorMsg);
getConversionErrorMessage(nonLeapDay, dateCol, Date.class), actualErrorMsg);

bulkImportText = String.format("%s\t\n%s", timeCol, badTime);
importPage.setText(bulkImportText);
actualErrorMsg = importPage.submitExpectingError();

checker().withScreenshot()
.verifyEquals("Error message for a bad time value not as expected.",
String.format(expectedTimeErrorMsgFormat, badTime, "Time", timeCol), actualErrorMsg);
getConversionErrorMessage(badTime, timeCol, Time.class), actualErrorMsg);

bulkImportText = String.format("%s\t\n%s", dateTimeCol, badDateTime);
importPage.setText(bulkImportText);
actualErrorMsg = importPage.submitExpectingError();

checker().withScreenshot()
.verifyEquals("Error message for a bad DateTime value not as expected.",
String.format(expectedDateErrorMsgFormat, badDateTime, "Timestamp", dateTimeCol), actualErrorMsg);
getConversionErrorMessage(badDateTime, dateTimeCol, Timestamp.class), actualErrorMsg);

File excelDateTimeFile = TestFileUtils.getSampleData("lists/Bad_Date_And_Time_Values.xlsx");
importPage = importPage.selectUpload();
Expand All @@ -1071,9 +1074,9 @@ public void testInvalidDateAndTimeInsert()

checker().withScreenshot()
.verifyTrue("Error message for bad file import not as expected.",
actualErrorMsg.contains(String.format(expectedTimeErrorMsgFormat, badTime, "Time", timeCol)) &&
actualErrorMsg.contains(String.format(expectedDateErrorMsgFormat, nonLeapDay, "Date", dateCol)) &&
actualErrorMsg.contains(String.format(expectedDateErrorMsgFormat, badDateTime, "Timestamp", dateTimeCol))
actualErrorMsg.contains(getConversionErrorMessage(badTime, timeCol, Time.class)) &&
actualErrorMsg.contains(getConversionErrorMessage(nonLeapDay, dateCol, Date.class)) &&
actualErrorMsg.contains(getConversionErrorMessage(badDateTime, dateTimeCol, Timestamp.class))
);

_listHelper.beginAtList(getProjectName(), listName);
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/tests/nab/NabAssayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -292,7 +293,7 @@ public void runUITests()
runFile(TEST_ASSAY_NAB_FILE2).
build()).doImport();

assertElementPresent(Locators.labkeyError.containing("'bad-date' is not a valid Date for Date using U.S. date parsing (MDY)."), 1);
assertElementPresent(Locators.labkeyError.containing(getConversionErrorMessage("bad-date", "Date", Date.class)), 1);
// These dates are SQL Server specific
// assertElementPresent(Locators.labkeyError.containing("Only dates between January 1, 1753 and December 31, 9999 are accepted."), 1);
assertElementPresent(Locators.labkeyError.containing("Only dates between "), 1);
Expand Down