Skip to content

Commit 161d45d

Browse files
Test coverage for Issue 50516 (#2443)
1 parent 4aaed7d commit 161d45d

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.labkey.test.tests;
1717

18+
import org.assertj.core.api.Assertions;
1819
import org.junit.BeforeClass;
1920
import org.junit.Test;
2021
import org.junit.experimental.categories.Category;
@@ -841,6 +842,62 @@ public void testCoreLinkedSchema()
841842
assertTrue("Columns should have included 'Name': " + colNames, colNames.contains("Name"));
842843
}
843844

845+
// coverage for Issue 50516: NPE from LinkedSchema$XmlFilterWhereClauseSource.getWhereClauses() when linked schema XML references bogus column
846+
@Test
847+
public void testCoreLinkedSchemaFilters()
848+
{
849+
String linkedSchemaName = "linkedCoreFilter";
850+
String sourceContainerPath = "/" + getProjectName() + "/" + STUDY_FOLDER;
851+
852+
String badFilter = """
853+
<tables xmlns="http://labkey.org/data/xml" xmlns:cv="http://labkey.org/data/xml/queryCustomView">
854+
<filters name="bad-filter">
855+
<cv:filter column="no_such_column" operator="in" value="1;2"/>
856+
</filters>
857+
<table tableName="containers" tableDbType="NOT_IN_DB">
858+
<filters ref="bad-filter"/>
859+
</table>
860+
</tables>
861+
""";
862+
String goodFilter = """
863+
<tables xmlns="http://labkey.org/data/xml" xmlns:cv="http://labkey.org/data/xml/queryCustomView">
864+
<filters name="good-filter">
865+
<cv:filter column="searchable" operator="eq" value="true"/>
866+
</filters>
867+
<table tableName="containers" tableDbType="NOT_IN_DB">
868+
<filters ref="good-filter"/>
869+
</table>
870+
</tables>
871+
""";
872+
873+
log("Create the linked schema on core with a filter referencing a non-existent column");
874+
_schemaHelper.createLinkedSchema(sourceContainerPath, linkedSchemaName, sourceContainerPath, null, "core", null, badFilter);
875+
876+
// browse to containers in the linked schema and verify the expected error
877+
log("Verify the bogus filter gets an appropriate error");
878+
goToSchemaBrowser();
879+
selectQuery(linkedSchemaName, "containers");
880+
// Issue 50516: NPE from LinkedSchema$XmlFilterWhereClauseSource.getWhereClauses() when linked schema XML references bogus column
881+
waitForText("Error creating linked schema table 'containers': Filter column 'no_such_column' not found.");
882+
883+
// update the linked schema to use a good filter
884+
_schemaHelper.updateLinkedSchema(sourceContainerPath, linkedSchemaName, sourceContainerPath, null, "core", null, goodFilter);
885+
886+
// browse to containers in the linked schema and view data in the containers table
887+
log("Verify container is visible via linked schema via 'searchable=true' filter");
888+
goToSchemaBrowser();
889+
// finding the dataRegion here is already success
890+
DataRegionTable table = viewQueryData(linkedSchemaName, "containers");
891+
// ensure that the current container appears here as expected
892+
checker().withScreenshot("current_container_not_present")
893+
.wrapAssertion(()-> Assertions.assertThat(table.getRowIndex("Name", STUDY_FOLDER))
894+
.as("container name not present in table")
895+
.isGreaterThan(-1));
896+
897+
// clean up after ourselves
898+
_schemaHelper.deleteSchema(sourceContainerPath, A_PEOPLE_SCHEMA_NAME);
899+
}
900+
844901
/*
845902
Test coverage : Issue 45347: Audit table data not available in linked schema
846903
*/

0 commit comments

Comments
 (0)