@Test public void getAllMatchedMembersNamesForGroup() throws Exception { Query query = mock(Query.class); when(this.oldcore.getQueryManager().createQuery(anyString(), eq(Query.HQL))).thenReturn(query); List<Object> members = Arrays.asList("one", "two", "three"); when(query.execute()).thenReturn(members); assertEquals(members, this.groupService.getAllMatchedMembersNamesForGroup(this.group.getFullName(), "foo", 3, 10, false, this.oldcore.getXWikiContext())); verify(query).setWiki("wiki"); verify(query).setOffset(10); verify(query).setLimit(3); verify(query).bindValue("groupdocname", this.group.getFullName()); verify(query).bindValue("groupclassname", "XWiki.XWikiGroups"); verify(query).bindValue("matchfield", "%foo%"); }
@Override public Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start, Boolean orderAsc, XWikiContext context) throws XWikiException { DocumentReference groupReference = this.currentMixedDocumentReferenceResolver.resolve(group); String localGroupReference = this.localWikiEntityReferenceSerializer.serialize(groupReference); Map<String, Object> parameters = new HashMap<>(); StringBuilder statement = new StringBuilder("SELECT field.value ") .append(createMatchGroupMembersWhereClause(localGroupReference, matchField, orderAsc, parameters)); try { QueryManager queryManager = context.getWiki().getStore().getQueryManager(); Query query = queryManager.createQuery(statement.toString(), Query.HQL); for (Map.Entry<String, Object> entry : parameters.entrySet()) { query.bindValue(entry.getKey(), entry.getValue()); } query.setOffset(start); query.setLimit(nb); query.setWiki(groupReference.getWikiReference().getName()); return query.execute(); } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }
XWikiGroupServiceImpl implements XWikiGroupService, EventListener { @Override public Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start, Boolean orderAsc, XWikiContext context) throws XWikiException { DocumentReference groupReference = this.currentMixedDocumentReferenceResolver.resolve(group); String localGroupReference = this.localWikiEntityReferenceSerializer.serialize(groupReference); Map<String, Object> parameters = new HashMap<>(); StringBuilder statement = new StringBuilder("SELECT field.value ") .append(createMatchGroupMembersWhereClause(localGroupReference, matchField, orderAsc, parameters)); try { QueryManager queryManager = context.getWiki().getStore().getQueryManager(); Query query = queryManager.createQuery(statement.toString(), Query.HQL); for (Map.Entry<String, Object> entry : parameters.entrySet()) { query.bindValue(entry.getKey(), entry.getValue()); } query.setOffset(start); query.setLimit(nb); query.setWiki(groupReference.getWikiReference().getName()); return query.execute(); } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } } }
XWikiGroupServiceImpl implements XWikiGroupService, EventListener { @Override public Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start, Boolean orderAsc, XWikiContext context) throws XWikiException { DocumentReference groupReference = this.currentMixedDocumentReferenceResolver.resolve(group); String localGroupReference = this.localWikiEntityReferenceSerializer.serialize(groupReference); Map<String, Object> parameters = new HashMap<>(); StringBuilder statement = new StringBuilder("SELECT field.value ") .append(createMatchGroupMembersWhereClause(localGroupReference, matchField, orderAsc, parameters)); try { QueryManager queryManager = context.getWiki().getStore().getQueryManager(); Query query = queryManager.createQuery(statement.toString(), Query.HQL); for (Map.Entry<String, Object> entry : parameters.entrySet()) { query.bindValue(entry.getKey(), entry.getValue()); } query.setOffset(start); query.setLimit(nb); query.setWiki(groupReference.getWikiReference().getName()); return query.execute(); } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }  }
XWikiGroupServiceImpl implements XWikiGroupService, EventListener { @Override public Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start, Boolean orderAsc, XWikiContext context) throws XWikiException { DocumentReference groupReference = this.currentMixedDocumentReferenceResolver.resolve(group); String localGroupReference = this.localWikiEntityReferenceSerializer.serialize(groupReference); Map<String, Object> parameters = new HashMap<>(); StringBuilder statement = new StringBuilder("SELECT field.value ") .append(createMatchGroupMembersWhereClause(localGroupReference, matchField, orderAsc, parameters)); try { QueryManager queryManager = context.getWiki().getStore().getQueryManager(); Query query = queryManager.createQuery(statement.toString(), Query.HQL); for (Map.Entry<String, Object> entry : parameters.entrySet()) { query.bindValue(entry.getKey(), entry.getValue()); } query.setOffset(start); query.setLimit(nb); query.setWiki(groupReference.getWikiReference().getName()); return query.execute(); } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }  @Override synchronized void init(XWiki xwiki, XWikiContext context); @Override synchronized void initCache(XWikiContext context); @Override synchronized void initCache(int iCapacity, XWikiContext context); @Override void flushCache(); @Override @Deprecated Collection<String> listGroupsForUser(String member, XWikiContext context); @Override @Deprecated void addUserToGroup(String username, String database, String group, XWikiContext context); @Override void replaceMemberInAllGroups(DocumentReference memberSourceReference,
        DocumentReference memberTargetReference, XWikiContext context); @Override void removeUserOrGroupFromAllGroups(String memberWiki, String memberSpace, String memberName,
        XWikiContext context); @Override @Deprecated List<String> listMemberForGroup(String group, XWikiContext context); @Override @Deprecated List<String> listAllGroups(XWikiContext context); @Override String getName(); @Override List<Event> getEvents(); @Override void onEvent(Event event, Object source, Object data); @Override List<?> getAllMatchedUsers(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order,
        XWikiContext context); @Override List<?> getAllMatchedGroups(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order,
        XWikiContext context); @Override int countAllMatchedUsers(Object[][] matchFields, XWikiContext context); @Override int countAllMatchedGroups(Object[][] matchFields, XWikiContext context); @Override Collection<String> getAllGroupsNamesForMember(String member, int nb, int start, XWikiContext context); @Override Collection<DocumentReference> getAllGroupsReferencesForMember(DocumentReference memberReference, int limit,
        int offset, XWikiContext context); @Override Collection<String> getAllMembersNamesForGroup(String group, int nb, int start, XWikiContext context); @Override Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start,
        Boolean orderAsc, XWikiContext context); @Override int countAllMatchedMembersNamesForGroup(String group, String filter, XWikiContext xcontext); @Override int countAllGroupsNamesForMember(String member, XWikiContext context); @Override int countAllMembersNamesForGroup(String group, XWikiContext context); }
XWikiGroupServiceImpl implements XWikiGroupService, EventListener { @Override public Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start, Boolean orderAsc, XWikiContext context) throws XWikiException { DocumentReference groupReference = this.currentMixedDocumentReferenceResolver.resolve(group); String localGroupReference = this.localWikiEntityReferenceSerializer.serialize(groupReference); Map<String, Object> parameters = new HashMap<>(); StringBuilder statement = new StringBuilder("SELECT field.value ") .append(createMatchGroupMembersWhereClause(localGroupReference, matchField, orderAsc, parameters)); try { QueryManager queryManager = context.getWiki().getStore().getQueryManager(); Query query = queryManager.createQuery(statement.toString(), Query.HQL); for (Map.Entry<String, Object> entry : parameters.entrySet()) { query.bindValue(entry.getKey(), entry.getValue()); } query.setOffset(start); query.setLimit(nb); query.setWiki(groupReference.getWikiReference().getName()); return query.execute(); } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }  @Override synchronized void init(XWiki xwiki, XWikiContext context); @Override synchronized void initCache(XWikiContext context); @Override synchronized void initCache(int iCapacity, XWikiContext context); @Override void flushCache(); @Override @Deprecated Collection<String> listGroupsForUser(String member, XWikiContext context); @Override @Deprecated void addUserToGroup(String username, String database, String group, XWikiContext context); @Override void replaceMemberInAllGroups(DocumentReference memberSourceReference,
        DocumentReference memberTargetReference, XWikiContext context); @Override void removeUserOrGroupFromAllGroups(String memberWiki, String memberSpace, String memberName,
        XWikiContext context); @Override @Deprecated List<String> listMemberForGroup(String group, XWikiContext context); @Override @Deprecated List<String> listAllGroups(XWikiContext context); @Override String getName(); @Override List<Event> getEvents(); @Override void onEvent(Event event, Object source, Object data); @Override List<?> getAllMatchedUsers(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order,
        XWikiContext context); @Override List<?> getAllMatchedGroups(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order,
        XWikiContext context); @Override int countAllMatchedUsers(Object[][] matchFields, XWikiContext context); @Override int countAllMatchedGroups(Object[][] matchFields, XWikiContext context); @Override Collection<String> getAllGroupsNamesForMember(String member, int nb, int start, XWikiContext context); @Override Collection<DocumentReference> getAllGroupsReferencesForMember(DocumentReference memberReference, int limit,
        int offset, XWikiContext context); @Override Collection<String> getAllMembersNamesForGroup(String group, int nb, int start, XWikiContext context); @Override Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start,
        Boolean orderAsc, XWikiContext context); @Override int countAllMatchedMembersNamesForGroup(String group, String filter, XWikiContext xcontext); @Override int countAllGroupsNamesForMember(String member, XWikiContext context); @Override int countAllMembersNamesForGroup(String group, XWikiContext context); static final EntityReference GROUPCLASS_REFERENCE; }