diff --git a/api/src/test/java/org/openmrs/module/datafilter/impl/BaseFilterTest.java b/api/src/test/java/org/openmrs/module/datafilter/impl/BaseFilterTest.java index 754c9ec..d5d3b44 100644 --- a/api/src/test/java/org/openmrs/module/datafilter/impl/BaseFilterTest.java +++ b/api/src/test/java/org/openmrs/module/datafilter/impl/BaseFilterTest.java @@ -27,7 +27,7 @@ public abstract class BaseFilterTest extends BaseModuleContextSensitiveTest { public Properties getRuntimeProperties() { Properties props = super.getRuntimeProperties(); //Fixes the error reported by the h2 driver in tests - props.setProperty(Environment.URL, props.getProperty(Environment.URL) + ";DB_CLOSE_ON_EXIT=FALSE"); + props.setProperty(Environment.URL, props.getProperty(Environment.URL) + ";DB_CLOSE_ON_EXIT=FALSE" + ";MODE=MYSQL"); return props; } diff --git a/api/src/test/java/org/openmrs/module/datafilter/impl/UserProgramBasedFilterTest.java b/api/src/test/java/org/openmrs/module/datafilter/impl/UserProgramBasedFilterTest.java index 59bee0d..45a8a7e 100644 --- a/api/src/test/java/org/openmrs/module/datafilter/impl/UserProgramBasedFilterTest.java +++ b/api/src/test/java/org/openmrs/module/datafilter/impl/UserProgramBasedFilterTest.java @@ -26,6 +26,7 @@ import org.openmrs.module.datafilter.TestConstants; import org.openmrs.module.datafilter.impl.api.DataFilterService; import org.openmrs.test.TestUtil; +import org.openmrs.util.DatabaseUtil; import org.openmrs.util.PrivilegeConstants; import org.springframework.beans.factory.annotation.Autowired; @@ -116,4 +117,25 @@ public void getUsers_shouldReturnAllUsersIfTheFilterIsDisabled() { assertEquals(7, getUsers().size()); } + @Test + public void getProvidersByPerson_shouldFailWithSQLSyntaxErrorException() throws Exception { + // Setup + String exception = "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')\n" + + " OR datafilter_ur.role NOT IN ()\n" + " ' at line 6"; + String sql = "DELETE FROM datafilter_entity_basis_map"; + FilterTestUtils.enableFilter(ImplConstants.PROGRAM_BASED_FILTER_NAME_USER); + DatabaseUtil.executeSQL(getConnection(), sql, false); + Context.logout(); + + // Replay + Context.addProxyPrivilege(PrivilegeConstants.GET_PERSONS); + Context.addProxyPrivilege(PrivilegeConstants.GET_PROVIDERS); + try { + Context.getProviderService().getProvidersByPerson(Context.getPersonService().getPerson(1001)); + } + catch (Exception e) { + assertEquals(exception, e.getCause().getMessage()); + } + } + }