Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
}
}

}