Skip to content

Commit 5b934ff

Browse files
committed
Handle double spaces in ListLookupTest
1 parent 7e46674 commit 5b934ff

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/org/labkey/test/params/FieldInfo.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private FieldInfo(FieldKey fieldKey, String label, ColumnType columnType, Consum
3737

3838
public FieldInfo(String name, String label, ColumnType columnType)
3939
{
40-
this(FieldKey.fromParts(name.trim()), label, columnType, null, null);
40+
this(FieldKey.fromParts(name.trim()), label, columnType, null, name);
4141
}
4242

4343
public FieldInfo(String name, String label)
@@ -60,8 +60,7 @@ public FieldInfo(String name)
6060
*/
6161
public static FieldInfo random(String namePart, ColumnType columnType)
6262
{
63-
FieldInfo field = new FieldInfo(FieldKey.fromParts(TestDataGenerator.randomFieldName(namePart)), null, columnType, null, namePart);
64-
return field;
63+
return new FieldInfo(FieldKey.fromParts(TestDataGenerator.randomFieldName(namePart)), null, columnType, null, namePart);
6564
}
6665

6766
/**

src/org/labkey/test/tests/list/ListLookupTest.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.util.Map;
2727

2828
import static org.junit.Assert.assertEquals;
29+
import static org.labkey.test.params.FieldDefinition.labelFromName;
30+
import static org.labkey.test.util.TextUtils.normalizeSpace;
2931

3032
// Issue 52098, Issue 49422
3133
@Category({Daily.class, Data.class, Hosting.class})
@@ -122,7 +124,8 @@ public void testWithoutValidatorOrAlternateKeys() throws IOException, CommandExc
122124
String error = importDataPage
123125
.setText(bulkData)
124126
.submitExpectingError();
125-
checker().withScreenshot().verifyEquals("Error message for invalid primary key not as expected", "Could not convert value 'noneSuch' (String) for Integer field '" + lookFromLookupFieldName + "'", error);
127+
checker().withScreenshot().verifyEquals("Error message for invalid primary key not as expected",
128+
"Could not convert value 'noneSuch' (String) for Integer field '" + normalizeSpace(lookFromLookupFieldName) + "'", error);
126129
}
127130

128131
@Test
@@ -168,7 +171,8 @@ public void testWithoutValidatorWithAlternateKeys() throws IOException, CommandE
168171
.setText(bulkData)
169172
.setImportLookupByAlternateKey(true)
170173
.submitExpectingError();
171-
checker().withScreenshot().verifyEquals("Error message after supplying invalid alternate key not as expected", "Value 'NotAValue' not found for field " + lookFromLookupFieldName + " in the current context.", error);
174+
checker().withScreenshot().verifyEquals("Error message after supplying invalid alternate key not as expected",
175+
"Value 'NotAValue' not found for field " + normalizeSpace(lookFromLookupFieldName) + " in the current context.", error);
172176
}
173177

174178
@Test
@@ -196,13 +200,16 @@ public void testWithLookupValidatorWithoutAlternateKeys() throws IOException, Co
196200
String error = importDataPage
197201
.setText(tsvFromColumn(List.of(lookFromLookupFieldName, "1000")))
198202
.submitExpectingError();
199-
checker().withScreenshot().verifyEquals("Error message for invalid primary key value not as expected", "Value '1000' was not present in lookup target 'lists." + lookToListName + "' for field '" + FieldDefinition.labelFromName(lookFromLookupFieldName) + "'", error);
203+
checker().withScreenshot().verifyEquals("Error message for invalid primary key value not as expected",
204+
"Value '1000' was not present in lookup target 'lists." + normalizeSpace(lookToListName)
205+
+ "' for field '" + normalizeSpace(labelFromName(lookFromLookupFieldName)) + "'", error);
200206

201207
log("With lookup validation on, import data and provide an invalid primary key of type string.");
202208
error = importDataPage
203209
.setText(tsvFromColumn(List.of(lookFromLookupFieldName, "Look")))
204210
.submitExpectingError();
205-
checker().withScreenshot().verifyEquals("Error message for invalid primary key type not as expected", "Could not convert value 'Look' (String) for Integer field '" + lookFromLookupFieldName + "'", error);
211+
checker().withScreenshot().verifyEquals("Error message for invalid primary key type not as expected",
212+
"Could not convert value 'Look' (String) for Integer field '" + normalizeSpace(lookFromLookupFieldName) + "'", error);
206213
}
207214

208215
@Test
@@ -246,14 +253,17 @@ public void testWithLookupValidatorAndAlternateKeys() throws IOException, Comman
246253
.setText(bulkData)
247254
.setImportLookupByAlternateKey(true)
248255
.submitExpectingError();
249-
checker().withScreenshot().verifyEquals("Error message for invalid string alternate key not as expected", "Value 'Invalid' not found for field " + lookFromLookupFieldName + " in the current context.", error);
256+
checker().withScreenshot().verifyEquals("Error message for invalid string alternate key not as expected",
257+
"Value 'Invalid' not found for field " + normalizeSpace(lookFromLookupFieldName) + " in the current context.", error);
250258

251259
bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, "1234"));
252260
error = importDataPage
253261
.setText(bulkData)
254262
.setImportLookupByAlternateKey(true)
255263
.submitExpectingError();
256-
checker().withScreenshot().verifyEquals("Error message for invalid number-like alternate key not as expected", "Value '1234' was not present in lookup target 'lists." + lookToListName + "' for field '" + FieldDefinition.labelFromName(lookFromLookupFieldName) + "'", error);
264+
checker().withScreenshot().verifyEquals("Error message for invalid number-like alternate key not as expected",
265+
"Value '1234' was not present in lookup target 'lists." + normalizeSpace(lookToListName)
266+
+ "' for field '" + normalizeSpace(labelFromName(lookFromLookupFieldName)) + "'", error);
257267

258268
}
259269

0 commit comments

Comments
 (0)