Skip to content

Commit 48d64b7

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_htmlwriter
2 parents 304d461 + 05b4b1c commit 48d64b7

File tree

7 files changed

+235
-114
lines changed

7 files changed

+235
-114
lines changed

src/org/labkey/test/tests/CustomizeViewTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@ public void saveFilterTest()
305305
String value = "J";
306306
String[] viewNames = {TRICKY_CHARACTERS + "view", "AAC", "aaa", "aad", "zzz"};
307307

308-
setColumns(fieldKey);
308+
setColumns(LAST_NAME_COLUMN);
309309
for(String name : viewNames)
310310
{
311311
_customizeViewsHelper.openCustomizeViewPanel();
312-
_customizeViewsHelper.addFilter(fieldKey, fieldKey, op, value);
312+
_customizeViewsHelper.addFilter(new String[]{fieldKey}, fieldKey, op, value);
313313
_customizeViewsHelper.saveCustomView(name);
314314
}
315315

src/org/labkey/test/tests/assay/UploadLargeExcelAssayTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected void doCleanup(boolean afterTest)
3939
@BeforeClass
4040
public static void setupProject() throws Exception
4141
{
42-
UploadLargeExcelAssayTest init = (UploadLargeExcelAssayTest) getCurrentTest();
42+
UploadLargeExcelAssayTest init = getCurrentTest();
4343

4444
init.doSetup();
4545
}
@@ -85,9 +85,8 @@ public void testUpload200kRows() throws Exception
8585
String fileName = "200kXlsxFile.xlsx";
8686
var dgen = new TestDataGenerator("samples", "chaos_sample", getProjectName())
8787
.withColumns(ASSAY_FIELDS);
88-
dgen.generateRows(200_000);
8988
log("writing large .xlsx file");
90-
var largeExcelFile = dgen.writeData(fileName);
89+
var largeExcelFile = dgen.writeData(fileName, 200_000);
9190
log("finished writing large .xlsx file");
9291

9392
// import large generated excel to assay1

src/org/labkey/test/tests/component/GridPanelTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.labkey.test.components.ui.search.FilterExpressionPanel;
2424
import org.labkey.test.components.ui.search.FilterFacetedPanel;
2525
import org.labkey.test.params.FieldDefinition;
26+
import org.labkey.test.params.FieldKey;
2627
import org.labkey.test.params.experiment.SampleTypeDefinition;
2728
import org.labkey.test.util.DataRegionTable;
2829
import org.labkey.test.util.SampleTypeHelper;
@@ -63,11 +64,11 @@ public class GridPanelTest extends GridPanelBaseTest
6364
// Column names.
6465
private static final String FILTER_NAME_COL = "Name";
6566
private static final String FILTER_EXPDATE_COL = "Expiration Date";
66-
private static final String FILTER_STRING_COL = TestDataGenerator.randomFieldName("Str", 0, 5);
67-
private static final String FILTER_INT_COL = TestDataGenerator.randomFieldName("Int", 0, 5);
68-
private static final String FILTER_EXTEND_CHAR_COL = TestDataGenerator.randomFieldName("\u0106\u00D8\u0139", 0, 5);
69-
private static final String FILTER_BOOL_COL = TestDataGenerator.randomFieldName("Bool", 0, 5);
70-
private static final String FILTER_DATE_COL = TestDataGenerator.randomFieldName("Date", 0, 5);
67+
private static final String FILTER_STRING_COL = "Str";
68+
private static final String FILTER_INT_COL = "Int";
69+
private static final String FILTER_EXTEND_CHAR_COL = "\u0106\u00D8\u0139";
70+
private static final String FILTER_BOOL_COL = "Bool";
71+
private static final String FILTER_DATE_COL = "Date";
7172
private static final String FILTER_STORED_AMOUNT_COL = "Amount";
7273

7374
// Views and columns used in the views. The views are only applied to the small sample type (Small_SampleType).
@@ -117,7 +118,7 @@ public class GridPanelTest extends GridPanelBaseTest
117118
@BeforeClass
118119
public static void setupProject() throws IOException, CommandException
119120
{
120-
GridPanelTest init = (GridPanelTest) getCurrentTest();
121+
GridPanelTest init = getCurrentTest();
121122

122123
init.doSetup();
123124
}
@@ -196,7 +197,7 @@ private void createSmallSampleType() throws IOException, CommandException
196197
cv.saveCustomView(VIEW_FEWER_COLUMNS);
197198

198199
log(String.format("Finally create a view named '%s' for '%s' that only has a filter.", VIEW_FILTERED_COLUMN, SMALL_SAMPLE_TYPE));
199-
drtSamples.setFilter(FILTER_STRING_COL, "Contains One Of", String.format("%1$s\n%1$s%2$s", stringSetMembers.get(0), stringSetMembers.get(1)));
200+
drtSamples.setFilter(FieldKey.encodePart(FILTER_STRING_COL), "Contains One Of", String.format("%1$s\n%1$s%2$s", stringSetMembers.get(0), stringSetMembers.get(1)));
200201
cv = drtSamples.openCustomizeGrid();
201202
cv.saveCustomView(VIEW_FILTERED_COLUMN);
202203

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

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.labkey.test.tests.list;
22

3+
import org.apache.commons.csv.CSVFormat;
34
import org.jetbrains.annotations.Nullable;
45
import org.junit.BeforeClass;
56
import org.junit.Test;
@@ -16,10 +17,12 @@
1617
import org.labkey.test.util.DataRegionTable;
1718
import org.labkey.test.util.EscapeUtil;
1819
import org.labkey.test.util.TestDataGenerator;
20+
import org.labkey.test.util.data.TestDataUtils;
1921
import org.labkey.test.util.query.QueryApiHelper;
2022

2123
import java.io.IOException;
2224
import java.util.Arrays;
25+
import java.util.Collections;
2326
import java.util.List;
2427
import java.util.Map;
2528

@@ -55,11 +58,12 @@ private void doSetup()
5558
log("Create a list to use as a lookup table with some number-like names.");
5659
_listHelper.createList(getProjectName(), lookToListName, lookToKeyFieldName,
5760
new FieldDefinition(lookToFieldName, FieldDefinition.ColumnType.String));
58-
String bulkData = lookToFieldName + "\n" +
59-
"1E2\n" +
60-
"102\n" +
61-
"Lookup\n" +
62-
".123";
61+
String bulkData = tsvFromColumn(List.of(
62+
lookToFieldName,
63+
"1E2",
64+
"102",
65+
"Lookup",
66+
".123"));
6367
_listHelper.bulkImportData(bulkData);
6468

6569
DataRegionTable dataRegionTable = new DataRegionTable("query", getDriver());
@@ -85,11 +89,12 @@ private void doSetup()
8589
@Test
8690
public void testWithoutValidatorOrAlternateKeys() throws IOException, CommandException
8791
{
92+
goToProjectHome();
8893
setLookupValidatorEnabled(false);
8994
resetList();
9095

9196
log("Import data into the second list without alternate keys.");
92-
String bulkData = lookFromLookupFieldName + "\n" + lookupKeyAsNameNumber;
97+
String bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, lookupKeyAsNameNumber));
9398
_listHelper.clickImportData()
9499
.setText(bulkData)
95100
.submit();
@@ -102,7 +107,7 @@ public void testWithoutValidatorOrAlternateKeys() throws IOException, CommandExc
102107
log("Clean out list before next import.");
103108
resetList();
104109
log("Import data into second list without alternate keys supplying invalid primary key");
105-
bulkData = lookFromLookupFieldName + "\n1000";
110+
bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, "1000"));
106111
_listHelper.clickImportData()
107112
.setText(bulkData)
108113
.submit();
@@ -113,7 +118,7 @@ public void testWithoutValidatorOrAlternateKeys() throws IOException, CommandExc
113118
validateListValues(expectedData);
114119

115120
log("Check for error if not using alternate key and type does not match");
116-
bulkData = lookFromLookupFieldName + "\nnoneSuch";
121+
bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, "noneSuch"));
117122
ImportDataPage importDataPage = _listHelper.clickImportData();
118123
String error = importDataPage
119124
.setText(bulkData)
@@ -124,20 +129,22 @@ public void testWithoutValidatorOrAlternateKeys() throws IOException, CommandExc
124129
@Test
125130
public void testWithoutValidatorWithAlternateKeys() throws IOException, CommandException
126131
{
132+
goToProjectHome();
127133
setLookupValidatorEnabled(false);
128134
log("Clean out list before next import.");
129135
resetList();
130136
log("Import data into the second list using number-like lookup values expecting alternate keys but also accepting primary keys.");
131-
String bulkData = lookFromLookupFieldName + "\n" +
132-
"1E2\n" + // valid alternate key looking like a number
133-
lookupKeyAsNameNumber + "\n" + // valid alternate key same value as a primary key
134-
".123\n" + // valid alternate key looking like a float
135-
"Lookup\n" + // valid alternate key that is a string
136-
lookupKeyAsNameNumber + "\n" + // another copy
137-
"102\n" + // valid number-like alternate key
138-
lookToListValues.get(1).get(EscapeUtil.fieldKeyEncodePart(lookToKeyFieldName)) + "\n" + // primary key value not matching an alternate key
139-
"1000" // primary key-type value that doesn't match
140-
;
137+
String bulkData = tsvFromColumn(List.of(
138+
lookFromLookupFieldName,
139+
"1E2", // valid alternate key looking like a number
140+
lookupKeyAsNameNumber, // valid alternate key same value as a primary key
141+
".123", // valid alternate key looking like a float
142+
"Lookup", // valid alternate key that is a string
143+
lookupKeyAsNameNumber, // another copy
144+
"102", // valid number-like alternate key
145+
lookToListValues.get(1).get(EscapeUtil.fieldKeyEncodePart(lookToKeyFieldName)), // primary key value not matching an alternate key
146+
"1000" // primary key-type value that doesn't match
147+
));
141148
_listHelper.clickImportData()
142149
.setText(bulkData)
143150
.setImportLookupByAlternateKey(true)
@@ -156,7 +163,7 @@ public void testWithoutValidatorWithAlternateKeys() throws IOException, CommandE
156163
validateListValues(expectedData);
157164

158165
log("Check for error if providing non-matching string value that is not a number");
159-
bulkData = lookFromLookupFieldName + "\nNotAValue";
166+
bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, "NotAValue"));
160167
ImportDataPage importDataPage = _listHelper.clickImportData();
161168
String error = importDataPage
162169
.setText(bulkData)
@@ -168,13 +175,14 @@ public void testWithoutValidatorWithAlternateKeys() throws IOException, CommandE
168175
@Test
169176
public void testWithLookupValidatorWithoutAlternateKeys() throws IOException, CommandException
170177
{
178+
goToProjectHome();
171179
setLookupValidatorEnabled(true);
172180
log("Clean out list before next import.");
173181
resetList();
174182

175183
// without alternate keys
176184
log("With lookup validation on, import data into the second list without alternate keys.");
177-
String bulkData = lookFromLookupFieldName + "\n" + lookupKeyAsNameNumber;
185+
String bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, lookupKeyAsNameNumber));
178186
_listHelper.clickImportData()
179187
.setText(bulkData)
180188
.submit();
@@ -187,34 +195,36 @@ public void testWithLookupValidatorWithoutAlternateKeys() throws IOException, Co
187195
log("With lookup validation on, import data and provide an invalid primary key.");
188196
ImportDataPage importDataPage = _listHelper.clickImportData();
189197
String error = importDataPage
190-
.setText(lookFromLookupFieldName + "\n1000")
198+
.setText(tsvFromColumn(List.of(lookFromLookupFieldName, "1000")))
191199
.submitExpectingError();
192-
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 '" + lookFromLookupFieldName + "'", error);
200+
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);
193201

194202
log("With lookup validation on, import data and provide an invalid primary key of type string.");
195203
error = importDataPage
196-
.setText(lookFromLookupFieldName + "\nLook")
204+
.setText(tsvFromColumn(List.of(lookFromLookupFieldName, "Look")))
197205
.submitExpectingError();
198206
checker().withScreenshot().verifyEquals("Error message for invalid primary key type not as expected", "Could not convert value 'Look' (String) for Integer field '" + lookFromLookupFieldName + "'", error);
199207
}
200208

201209
@Test
202210
public void testWithLookupValidatorAndAlternateKeys() throws IOException, CommandException
203211
{
212+
goToProjectHome();
204213
setLookupValidatorEnabled(true);
205214
log("Clean out list before next import.");
206215
resetList();
207216

208217
log("With lookup validation on, import data into the second list using number-like lookup values expecting alternate keys but also accepting primary keys.");
209-
String bulkData = lookFromLookupFieldName + "\n" +
210-
"1E2\n" + // valid alternate key looking like a number
211-
lookupKeyAsNameNumber + "\n" + // valid alternate key same value as a primary key
212-
".123\n" + // valid alternate key looking like a float
213-
"Lookup\n" + // valid alternate key that is a string
214-
lookupKeyAsNameNumber + "\n" + // another copy
215-
"102\n" + // valid number-like alternate key
216-
lookToListValues.get(1).get(EscapeUtil.fieldKeyEncodePart(lookToKeyFieldName)) + "\n" // primary key value not matching an alternate key
217-
;
218+
String bulkData = tsvFromColumn(List.of(
219+
lookFromLookupFieldName,
220+
"1E2", // valid alternate key looking like a number
221+
lookupKeyAsNameNumber, // valid alternate key same value as a primary key
222+
".123", // valid alternate key looking like a float
223+
"Lookup", // valid alternate key that is a string
224+
lookupKeyAsNameNumber, // another copy
225+
"102", // valid number-like alternate key
226+
lookToListValues.get(1).get(EscapeUtil.fieldKeyEncodePart(lookToKeyFieldName)) // primary key value not matching an alternate key
227+
));
218228
_listHelper.clickImportData()
219229
.setText(bulkData)
220230
.setImportLookupByAlternateKey(true)
@@ -231,20 +241,20 @@ public void testWithLookupValidatorAndAlternateKeys() throws IOException, Comman
231241
);
232242
validateListValues(expectedData);
233243

234-
bulkData = lookFromLookupFieldName + "\nInvalid";
244+
bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, "Invalid"));
235245
ImportDataPage importDataPage = _listHelper.clickImportData();
236246
String error = importDataPage
237247
.setText(bulkData)
238248
.setImportLookupByAlternateKey(true)
239249
.submitExpectingError();
240250
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);
241251

242-
bulkData = lookFromLookupFieldName + "\n1234";
252+
bulkData = tsvFromColumn(List.of(lookFromLookupFieldName, "1234"));
243253
error = importDataPage
244254
.setText(bulkData)
245255
.setImportLookupByAlternateKey(true)
246256
.submitExpectingError();
247-
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 '" + lookFromLookupFieldName + "'", error);
257+
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);
248258

249259
}
250260

@@ -273,6 +283,12 @@ private void validateListValues(List<Map<String, String>> expectedValue)
273283
expectedValue, actualValue);
274284
}
275285

286+
private String tsvFromColumn(List<String> column)
287+
{
288+
List<List<String>> rows = column.stream().map(Collections::singletonList).toList();
289+
return TestDataUtils.stringFromRows(rows, CSVFormat.TDF);
290+
}
291+
276292
@Override
277293
protected @Nullable String getProjectName()
278294
{

src/org/labkey/test/util/Crawler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ protected List<ControllerActionId> getDefaultExcludedActions()
199199
// Tested directly in XTandemTest
200200
new ControllerActionId("protein", "doProteinSearch"),
201201
new ControllerActionId("protein", "pepSearch"), // TODO: Issue 36995: Check for SQL injection in StatementWrapper is not precise enough
202+
new ControllerActionId("publish", "sampleTypePublishConfirm"), // POST-only
203+
new ControllerActionId("publish", "assayPublishConfirm"), // POST-only
202204
new ControllerActionId("query", "printRows"), // Data region print button. 404s on "TargetedMS Runs" grid
203205
new ControllerActionId("reports", "streamFile"),
204206
new ControllerActionId("study", "manageStudyProperties"), // Intermittently triggers form dirty alert

0 commit comments

Comments
 (0)