|
15 | 15 | */ |
16 | 16 | package org.labkey.test.tests; |
17 | 17 |
|
| 18 | +import org.assertj.core.api.Assertions; |
18 | 19 | import org.junit.BeforeClass; |
19 | 20 | import org.junit.Test; |
20 | 21 | import org.junit.experimental.categories.Category; |
@@ -841,6 +842,62 @@ public void testCoreLinkedSchema() |
841 | 842 | assertTrue("Columns should have included 'Name': " + colNames, colNames.contains("Name")); |
842 | 843 | } |
843 | 844 |
|
| 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 | + |
844 | 901 | /* |
845 | 902 | Test coverage : Issue 45347: Audit table data not available in linked schema |
846 | 903 | */ |
|
0 commit comments