use of org.xwiki.query.internal.DefaultQuery in project xwiki-platform by xwiki.
the class HqlQueryExecutorTest method execute.
private void execute(String statement, Boolean withProgrammingRights) throws QueryException {
this.hasProgrammingRight = withProgrammingRights != null ? withProgrammingRights : true;
DefaultQuery query = new DefaultQuery(statement, Query.HQL, this.executor);
if (withProgrammingRights != null) {
query.checkCurrentAuthor(true);
}
this.executor.execute(query);
}
use of org.xwiki.query.internal.DefaultQuery in project xwiki-platform by xwiki.
the class HqlQueryExecutorTest method executeNamed.
private void executeNamed(String name, Boolean withProgrammingRights) throws QueryException {
this.hasProgrammingRight = withProgrammingRights;
DefaultQuery query = new DefaultQuery(name, this.executor);
if (withProgrammingRights != null) {
query.checkCurrentAuthor(true);
}
this.executor.execute(query);
}
use of org.xwiki.query.internal.DefaultQuery in project xwiki-platform by xwiki.
the class SolrQueryExecutorTest method testMultiValuedQueryArgs.
@Test
public void testMultiValuedQueryArgs() throws Exception {
when(solr.query(any(SolrQuery.class))).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
SolrQuery solrQuery = (SolrQuery) invocation.getArguments()[0];
Assert.assertArrayEquals(ITERABLE_PARAM_EXPECTED, solrQuery.getParams(ITERABLE_PARAM_NAME));
Assert.assertArrayEquals(INT_ARR_PARAM_EXPECTED, solrQuery.getParams(INT_ARR_PARAM_NAME));
Assert.assertArrayEquals(STR_ARR_PARAM_EXPECTED, solrQuery.getParams(STR_ARR_PARAM_NAME));
Assert.assertEquals(SINGLE_PARAM_EXPECTED, solrQuery.get(SINGLE_PARAM_NAME));
// Check that the default list of supported locales is taken from the wiki configuration.
Assert.assertEquals("en,fr,de", solrQuery.get("xwiki.supportedLocales"));
QueryResponse r = mock(QueryResponse.class);
when(r.getResults()).thenReturn(new SolrDocumentList());
return r;
}
});
DefaultQuery query = new DefaultQuery("TestQuery", null);
query.bindValue(ITERABLE_PARAM_NAME, ITERABLE_PARAM_VALUE);
query.bindValue(INT_ARR_PARAM_NAME, INT_ARR_PARAM_VALUE);
query.bindValue(STR_ARR_PARAM_NAME, STR_ARR_PARAM_VALUE);
query.bindValue(SINGLE_PARAM_NAME, SINGLE_PARAM_VALUE);
// The default list of supported locales should be taken from the wiki configuration.
XWikiContext xcontext = this.oldCore.getXWikiContext();
doReturn(Arrays.asList(Locale.ENGLISH, Locale.FRENCH, Locale.GERMAN)).when(this.oldCore.getSpyXWiki()).getAvailableLocales(xcontext);
this.componentManager.getComponentUnderTest().execute(query);
}
Aggregations