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);
}
}
}
Aggregations