@Override public Object execute() throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { return execute(EMPTY_ARRAY); }
@Test public void queryIsPostProcessedWithSingleResultValue() throws Exception { authorize(DATA, READ, REGION, ALL); when(security.postProcess(any(), any(), any())).thenReturn("spam"); DefaultQuery query = mockQuery(); String queryString = "select * from /region"; Object[] bindParameters = {"a"}; when(query.execute(bindParameters)).thenReturn("value"); Object result = authorizingCache.query(queryString, bindParameters); assertEquals("spam", result); }
"Prevent multiple region query from being executed through region.query()"); results = (SelectResults) query.execute(params);
@Override public Object execute(RegionFunctionContext context, Object[] params) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { // Supported only with RegionFunctionContext if (context == null) { throw new IllegalArgumentException( "'Function Context' cannot be null"); } this.isQueryWithFunctionContext = true; if (params == null) { throw new IllegalArgumentException( "'parameters' cannot be null"); } long startTime = 0L; if (this.traceOn && this.cache != null) { startTime = NanoTimer.getTime(); } QueryObserver indexObserver = null; QueryExecutor qe = checkQueryOnPR(params); Object result = null; try { indexObserver = startTrace(); if (qe != null) { LocalDataSet localDataSet =
@Test public void queryIsPostProcessedWithListOfStructValues() throws Exception { authorize(DATA, READ, REGION, ALL); when(security.postProcess(any(), any(), any())).thenReturn("spam"); SelectResults<Struct> results = buildListOfStructs("value1", "value2"); DefaultQuery query = mockQuery(); String queryString = "select * from /region"; Object[] bindParameters = {"a"}; when(query.execute((Object[]) any())).thenReturn(results); SelectResults<String> result = (SelectResults<String>) authorizingCache.query(queryString, bindParameters); assertEquals(buildListOfStructs("spam", "spam").asList(), result.asList()); }
@Test public void queryIsPostProcessedWithListOfObjectValues() throws Exception { authorize(DATA, READ, REGION, ALL); when(security.postProcess(any(), any(), any())).thenReturn("spam"); DefaultQuery query = mockQuery(); String queryString = "select * from /region"; Object[] bindParameters = {"a"}; SelectResults results = new ResultsBag(); results.setElementType(new ObjectTypeImpl(Object.class)); results.add("value1"); results.add("value2"); when(query.execute((Object[]) any())).thenReturn(results); SelectResults<String> result = (SelectResults<String>) authorizingCache.query(queryString, bindParameters); assertEquals(Arrays.asList("spam", "spam"), result.asList()); }