Search in sources :

Example 1 with QueryBuilder

use of org.xwiki.query.QueryBuilder in project xwiki-platform by xwiki.

the class AbstractListClassPropertyValuesProviderTest method addProperty.

protected void addProperty(String name, PropertyClass definition, boolean withQueryBuilders) throws Exception {
    XWiki xwiki = this.xcontext.getWiki();
    BaseClass xclass = this.classDocument.getXClass();
    ClassPropertyReference propertyReference = new ClassPropertyReference(name, this.classReference);
    when(xwiki.getDocument(propertyReference, this.xcontext)).thenReturn(this.classDocument);
    when(xclass.get(name)).thenReturn(definition);
    definition.setOwnerDocument(this.classDocument);
    if (withQueryBuilders) {
        DefaultParameterizedType allowedValuesQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, definition.getClass());
        QueryBuilder allowedValuesQueryBuilder = getMocker().getInstance(allowedValuesQueryBuilderType);
        when(allowedValuesQueryBuilder.build(definition)).thenReturn(this.allowedValuesQuery);
        if (definition instanceof ListClass) {
            DefaultParameterizedType usedValuesQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, ListClass.class);
            this.usedValuesQueryBuilder = getMocker().getInstance(usedValuesQueryBuilderType, "usedValues");
            when(this.usedValuesQueryBuilder.build((ListClass) definition)).thenReturn(this.usedValuesQuery);
        }
    }
}
Also used : ListClass(com.xpn.xwiki.objects.classes.ListClass) BaseClass(com.xpn.xwiki.objects.classes.BaseClass) XWiki(com.xpn.xwiki.XWiki) QueryBuilder(org.xwiki.query.QueryBuilder) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) ClassPropertyReference(org.xwiki.model.reference.ClassPropertyReference)

Aggregations

XWiki (com.xpn.xwiki.XWiki)1 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)1 ListClass (com.xpn.xwiki.objects.classes.ListClass)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 ClassPropertyReference (org.xwiki.model.reference.ClassPropertyReference)1 QueryBuilder (org.xwiki.query.QueryBuilder)1