DBUserInfoImpl extends AbstractUserGroupInfo implements UserInfo { @Override public String getEmailForEntity(OrganizationalEntity entity) { Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; String emailAddress = null; try { conn = ds.getConnection(); ps = conn.prepareStatement(this.config.getProperty(EMAIL_QUERY)); ps.setString(1, entity.getId()); rs = ps.executeQuery(); if (rs.next()) { emailAddress = rs.getString(1); } } catch (Exception e) { logger.error("Error when fetching email address from db for entity {}", entity.getId(), e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { } } if (ps != null) { try { ps.close(); } catch (SQLException e) { } } if (conn != null) { try { conn.close(); } catch (Exception ex) { } } } return emailAddress; } DBUserInfoImpl(boolean activate);  DBUserInfoImpl(Properties config); @Override String getDisplayName(OrganizationalEntity entity); @Override String getEntityForEmail(String email); @Override Iterator<OrganizationalEntity> getMembersForGroup(Group group); @Override boolean hasEmail(Group group); @Override String getEmailForEntity(OrganizationalEntity entity); @Override String getLanguageForEntity(OrganizationalEntity entity); static final String DS_JNDI_NAME; static final String NAME_QUERY; static final String EMAIL_QUERY; static final String LANG_QUERY; static final String HAS_EMAIL_QUERY; static final String MEMBERS_QUERY; static final String ID_QUERY; }
@Test public void testGetEmailForEntity() { DBUserInfoImpl userInfo = new DBUserInfoImpl(props); String email = userInfo.getEmailForEntity(JOHN); Assertions.assertThat(email).isEqualTo("john@jbpm.org"); }