DBUserInfoImpl extends AbstractUserGroupInfo implements UserInfo { @Override public Iterator<OrganizationalEntity> getMembersForGroup(Group group) { List<OrganizationalEntity> roles = new ArrayList<OrganizationalEntity>(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = ds.getConnection(); ps = conn.prepareStatement(this.config.getProperty(MEMBERS_QUERY)); try { ps.setString(1, group.getId()); } catch (ArrayIndexOutOfBoundsException ignore) { } rs = ps.executeQuery(); while (rs.next()) { roles.add(TaskModelProvider.getFactory().newUser(rs.getString(1))); } } catch (Exception e) { logger.error("Error when fetching members of a group from db, groups id: ", group.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 roles.iterator(); } 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 testGetMembersForGroup() { DBUserInfoImpl userInfo = new DBUserInfoImpl(props); Iterator<OrganizationalEntity> members = userInfo.getMembersForGroup(PM); Assertions.assertThat(members.hasNext()).isTrue(); User user = (User) members.next(); Assertions.assertThat(user.getId()).isEqualTo(JOHN.getId()); }