GroovyPersonAttributeDao extends AbstractDefaultAttributePersonAttributeDao { @Override public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(final Map<String, List<Object>> attributes, final IPersonAttributeDaoFilter filter) { logger.debug("Executing groovy script's getPersonAttributesFromMultivaluedAttributes method, with parameters {}", attributes); final Map<String, List<Object>> personAttributesMap = groovyObject.getPersonAttributesFromMultivaluedAttributes(attributes); if (personAttributesMap != null) { logger.debug("Creating person attributes: {}", personAttributesMap); return Collections.singleton(new AttributeNamedPersonImpl(personAttributesMap)); } return null; } GroovyPersonAttributeDao(final IPersonAttributeScriptDao groovyObject); void setCaseInsensitiveUsername(final boolean caseInsensitiveUsername); @Override IPersonAttributes getPerson(final String uid, final IPersonAttributeDaoFilter filter); @Override Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(final Map<String, List<Object>> attributes,
                                                                     final IPersonAttributeDaoFilter filter); void setPossibleUserAttributeNames(final Set<String> possibleUserAttributeNames); void setAvailableQueryAttributes(final Set<String> availableQueryAttributes); @Override Set<String> getAvailableQueryAttributes(final IPersonAttributeDaoFilter filter); @Override Set<String> getPossibleUserAttributeNames(final IPersonAttributeDaoFilter filter);  }
@Test public void testGetPeopleWithMultivaluedAttributes() { final Set<IPersonAttributes> results = dao.getPeopleWithMultivaluedAttributes(items, IPersonAttributeDaoFilter.alwaysChoose()); assertEquals("script did not add one attribute to passed-in attribute list", items.size() + 1, results.iterator().next().getAttributes().size()); }
@Test public void testGetPeopleWithMultivaluedAttributesNullResult() { GroovyPersonAttributeDao nullResponseDao = new GroovyPersonAttributeDao(loadGroovyClass("SampleGroovyPersonAttributeDaoForTestingUpdates.groovy")); final Set<IPersonAttributes> results = nullResponseDao.getPeopleWithMultivaluedAttributes(items, IPersonAttributeDaoFilter.alwaysChoose()); assertNull(results); }