Skip to content
Open
14 changes: 10 additions & 4 deletions src/org/labkey/test/LabKeySiteWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1721,23 +1721,29 @@ protected void deletePipelineJob(@LoggedParam String jobDescription, @LoggedPara

public String getConversionErrorMessage(Object value, String fieldName, Class<?> targetClass)
{
return getConversionErrorMessage(value, fieldName, targetClass, true);
return getConversionErrorMessage(value, fieldName, targetClass, true, false);
}

// Note: Keep in sync with ConvertHelper.getStandardConversionErrorMessage()
// Example: "Could not convert value '2.34' (Double) for Boolean field 'Medical History.Dep Diagnosed in Last 18 Months'"
public String getConversionErrorMessage(Object value, String fieldName, Class<?> targetClass, boolean useUSDateParsing)
public String getConversionErrorMessage(Object value, String fieldName, Class<?> targetClass, boolean useUSDateParsing, boolean withoutSingleQuotes)
{
String errorMessage;
String fieldType = targetClass.getSimpleName();
String quote = withoutSingleQuotes ? "" : "'";

// Issue 50768: Need a better error message if date value is not in the expected format.
if (fieldType.equalsIgnoreCase("date") || fieldType.equalsIgnoreCase("datetime") || fieldType.equalsIgnoreCase("timestamp"))
{
String parsingMode = useUSDateParsing ? "U.S. date parsing (MDY)" : "Non-U.S. date parsing (DMY)";
return "'" + value + "' is not a valid " + fieldType + " for " + fieldName + " using " + parsingMode;
errorMessage = quote + value + quote + " is not a valid " + fieldType + " for " + fieldName + " using " + parsingMode;
}
else
{
errorMessage = "Could not convert value " + quote + value + quote + " (" + value.getClass().getSimpleName() + ") for " + fieldType + " field " + quote + fieldName + quote;
}

return "Could not convert value '" + value + "' (" + value.getClass().getSimpleName() + ") for " + fieldType + " field '" + fieldName + "'" ;
return errorMessage;
}

private ProductKey getProductConfiguration() throws IOException, CommandException
Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/test/tests/InlineImagesListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public final void testList() throws Exception
importFilePathError(listImportPage, "1", PDF_FILE.getName());
importFilePathError(listImportPage, "5", PDF_FILE.getName());

String attachmentError = "Can't upload '%s' to field %s with type Attachment.";
String attachmentError = "Cannot upload '%s' to Attachment type field '%s'.";
String attachmentPdfError = String.format(attachmentError, PDF_FILE.getName(), LIST_ATTACHMENT01_NAME);
String attachmentAbsentError = String.format(attachmentError, "Absent.txt", LIST_ATTACHMENT01_NAME);
verifyQueryAPI("lists", LIST_NAME, Map.of(LIST_KEY_NAME, 5, LIST_ATTACHMENT01_NAME, PDF_FILE.getName()), true, "Row 1: " + attachmentPdfError);
Expand All @@ -397,7 +397,7 @@ private void importFilePathError(ImportDataPage listImportPage, String key, Stri
listImportPage.submitExpectingError();
try
{
String expectedError = "Row 1: Can't upload '" + attachmentValue + "' to field " + LIST_ATTACHMENT01_NAME + " with type Attachment.";
String expectedError = "Row 1: Cannot upload '" + attachmentValue + "' to Attachment type field '" + LIST_ATTACHMENT01_NAME + "'.";
checker().withScreenshot("import_error").verifyTrue("Invalid attachment error not as expected", isElementPresent(Locator.tagWithClass("div", "labkey-error").withText(expectedError)));
}
catch(NoSuchElementException nse)
Expand Down
16 changes: 8 additions & 8 deletions src/org/labkey/test/tests/SampleTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1883,11 +1883,11 @@ public void testAmountsAndUnitsWithDisplayUnit()

log("verify error when inserting a row with an amount but no unit");
sampleHelper.insertRow(Map.of("Name", "AU-ERR-1", "StoredAmount", "0.0"));
assertTextPresent("No Units value provided for Amount 0.0.");
assertTextPresent("No 'Units' value provided for Amount '0.0'.");
clickButton("Cancel");
log("verify error when inserting a row with a unit but no amount");
sampleHelper.insertRow(Map.of("Name", "AU-ERR-2", "Units", "mL"));
assertTextPresent("No Amount value provided for Units mL.");
assertTextPresent("No 'Amount' value provided for Units 'mL'.");
clickButton("Cancel");

log("verify error when inserting a row with incompatible units");
Expand Down Expand Up @@ -1962,11 +1962,11 @@ public void testAmountsAndUnitsWithoutDisplayUnit()
log("verify that inserting a row with an amount or unit requires both fields to be filled in");
// insert row with amount but not unit (error expected)
sampleHelper.insertRow(Map.of("Name", "AU-ERR-1", "StoredAmount", "5.0"));
assertTextPresent("No Units value provided for Amount 5.0.");
assertTextPresent("No 'Units' value provided for Amount '5.0'.");
clickButton("Cancel");
// insert row with unit but not amount (error expected)
sampleHelper.insertRow(Map.of("Name", "AU-ERR-2", "Units", "mg"));
assertTextPresent("No Amount value provided for Units mg.");
assertTextPresent("No 'Amount' value provided for Units 'mg'.");
clickButton("Cancel");
// insert row with both amount and unit (success)
sampleHelper.insertRow(Map.of("Name", "AU-SUCCESS-1", "StoredAmount", "5.0", "Units", "mg"));
Expand All @@ -1975,11 +1975,11 @@ public void testAmountsAndUnitsWithoutDisplayUnit()
log("verify that updating a row with an amount or unit requires both fields to be filled in");
// update row with amount but not unit (error expected)
sampleHelper.updateRow(0, Map.of("Units", ""));
assertTextPresent("No Units value provided for Amount 5.0.");
assertTextPresent("No 'Units' value provided for Amount '5.0'.");
clickButton("Cancel");
// update row with unit but not amount (error expected)
sampleHelper.updateRow(0, Map.of("StoredAmount", ""));
assertTextPresent("No Amount value provided for Units mg.");
assertTextPresent("No 'Amount' value provided for Units 'mg'.");
clickButton("Cancel");
// update row with both amount and unit (success)
sampleHelper.updateRow(0, Map.of("StoredAmount", "10.0123", "Units", "g"));
Expand All @@ -1988,11 +1988,11 @@ public void testAmountsAndUnitsWithoutDisplayUnit()
log("verify that bulk import with an amount or unit requires both fields to be filled in");
// bulk import with amount but not unit (error expected)
sampleHelper.bulkImportExpectingError(List.of(Map.of("Name", "AU-BULK-ERR-1", "StoredAmount", "0")), SampleTypeHelper.IMPORT_OPTION);
assertTextPresent("A Units value must be provided when Amounts are provided");
assertTextPresent("A 'Units' value must be provided when 'Amounts' are provided");
clickButton("Cancel");
// bulk import with unit but not amount (error expected)
sampleHelper.bulkImportExpectingError(List.of(Map.of("Name", "AU-BULK-ERR-2", "Units", "mL")), SampleTypeHelper.IMPORT_OPTION);
assertTextPresent("An Amount value must be provided when Units are provided.");
assertTextPresent("An 'Amount' value must be provided when 'Units' are provided.");
clickButton("Cancel");
// bulk import with both amount and unit (success expected)
sampleHelper.bulkImport(List.of(Map.of("Name", "AU-BULK-SUCCESS-1", "StoredAmount", "0", "Units", "L")));
Expand Down