From 97ee8b606c0ebf21dadef764e380e401359387d8 Mon Sep 17 00:00:00 2001 From: ChrisJoosse Date: Fri, 9 May 2025 12:55:10 -0700 Subject: [PATCH 1/3] Test coverage for Issue 50516 --- .../labkey/test/tests/LinkedSchemaTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/org/labkey/test/tests/LinkedSchemaTest.java b/src/org/labkey/test/tests/LinkedSchemaTest.java index e42a545b13..1bd9df39a1 100644 --- a/src/org/labkey/test/tests/LinkedSchemaTest.java +++ b/src/org/labkey/test/tests/LinkedSchemaTest.java @@ -15,6 +15,7 @@ */ package org.labkey.test.tests; +import org.assertj.core.api.Assertions; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -841,6 +842,59 @@ public void testCoreLinkedSchema() assertTrue("Columns should have included 'Name': " + colNames, colNames.contains("Name")); } + // coverage for Issue 50516: NPE from LinkedSchema$XmlFilterWhereClauseSource.getWhereClauses() when linked schema XML references bogus column + @Test + public void testCoreLinkedSchemaFilters() + { + String linkedSchemaName = "linkedCoreFilter"; + String sourceContainerPath = "/" + getProjectName() + "/" + STUDY_FOLDER; + + String badFilter = """ + + + + + + +
+
+ """; + String goodFilter = """ + + + + + + +
+
+ """; + + log("Create the linked schema on core with a filter referencing a non-existent column"); + _schemaHelper.createLinkedSchema(sourceContainerPath, linkedSchemaName, sourceContainerPath, null, "core", null, badFilter); + + // browse to containers in the linked schema and verify the expected error + log("Verify the bogus filter gets an appropriate error"); + goToSchemaBrowser(); + selectQuery(linkedSchemaName, "containers"); + // Issue 50516: NPE from LinkedSchema$XmlFilterWhereClauseSource.getWhereClauses() when linked schema XML references bogus column + waitForText("Error creating linked schema table 'containers': Filter column 'no_such_column' not found."); + + _schemaHelper.updateLinkedSchema(sourceContainerPath, linkedSchemaName, sourceContainerPath, null, "core", null, goodFilter); + + // browse to containers in the linked schema and view data in the containers table + log("Verify container is visible via linked schema via 'searchable=true' filter"); + goToSchemaBrowser(); + // finding the dataRegion here is already success + DataRegionTable table = viewQueryData(linkedSchemaName, "containers"); + checker().withScreenshot("current_container_not_present") + .wrapAssertion(()-> Assertions.assertThat(table.getRowIndex("Name", "StudyFolder")) + .as("container name not present in table") + .isGreaterThan(-1)); + + _schemaHelper.deleteSchema(sourceContainerPath, A_PEOPLE_SCHEMA_NAME); + } + /* Test coverage : Issue 45347: Audit table data not available in linked schema */ From b4c5bca94159010343970ca021aea97d1be0fd60 Mon Sep 17 00:00:00 2001 From: ChrisJoosse Date: Fri, 9 May 2025 13:05:27 -0700 Subject: [PATCH 2/3] cleanup, comments --- src/org/labkey/test/tests/LinkedSchemaTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/org/labkey/test/tests/LinkedSchemaTest.java b/src/org/labkey/test/tests/LinkedSchemaTest.java index 1bd9df39a1..a7c85d3a19 100644 --- a/src/org/labkey/test/tests/LinkedSchemaTest.java +++ b/src/org/labkey/test/tests/LinkedSchemaTest.java @@ -880,6 +880,7 @@ public void testCoreLinkedSchemaFilters() // Issue 50516: NPE from LinkedSchema$XmlFilterWhereClauseSource.getWhereClauses() when linked schema XML references bogus column waitForText("Error creating linked schema table 'containers': Filter column 'no_such_column' not found."); + // update the linked schema to use a good filter _schemaHelper.updateLinkedSchema(sourceContainerPath, linkedSchemaName, sourceContainerPath, null, "core", null, goodFilter); // browse to containers in the linked schema and view data in the containers table @@ -887,11 +888,13 @@ public void testCoreLinkedSchemaFilters() goToSchemaBrowser(); // finding the dataRegion here is already success DataRegionTable table = viewQueryData(linkedSchemaName, "containers"); + // ensure that the current container appears here as expected checker().withScreenshot("current_container_not_present") .wrapAssertion(()-> Assertions.assertThat(table.getRowIndex("Name", "StudyFolder")) .as("container name not present in table") .isGreaterThan(-1)); + // clean up after ourselves _schemaHelper.deleteSchema(sourceContainerPath, A_PEOPLE_SCHEMA_NAME); } From a0c71cd5ed71cb7cf007cbb0a7527ac0de34ca1f Mon Sep 17 00:00:00 2001 From: ChrisJoosse Date: Fri, 9 May 2025 13:06:15 -0700 Subject: [PATCH 3/3] use folder constant --- src/org/labkey/test/tests/LinkedSchemaTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/labkey/test/tests/LinkedSchemaTest.java b/src/org/labkey/test/tests/LinkedSchemaTest.java index a7c85d3a19..d8494d75f9 100644 --- a/src/org/labkey/test/tests/LinkedSchemaTest.java +++ b/src/org/labkey/test/tests/LinkedSchemaTest.java @@ -890,7 +890,7 @@ public void testCoreLinkedSchemaFilters() DataRegionTable table = viewQueryData(linkedSchemaName, "containers"); // ensure that the current container appears here as expected checker().withScreenshot("current_container_not_present") - .wrapAssertion(()-> Assertions.assertThat(table.getRowIndex("Name", "StudyFolder")) + .wrapAssertion(()-> Assertions.assertThat(table.getRowIndex("Name", STUDY_FOLDER)) .as("container name not present in table") .isGreaterThan(-1));