Package com.gemstone.gemfire.cache.query

Examples of com.gemstone.gemfire.cache.query.QueryService


   */
  @Override
  @SuppressWarnings("unchecked")
  public <E> SelectResults<E> find(final String queryString, final Object... params) throws InvalidDataAccessApiUsageException {
    try {
      QueryService queryService = lookupQueryService(getRegion());
      Query query = queryService.newQuery(queryString);
      Object result = query.execute(params);

      if (result instanceof SelectResults) {
        return (SelectResults<E>) result;
      }
View Full Code Here


   */
  @Override
  @SuppressWarnings("unchecked")
  public <T> T findUnique(final String queryString, final Object... params) throws InvalidDataAccessApiUsageException {
    try {
      QueryService queryService = lookupQueryService(getRegion());
      Query query = queryService.newQuery(queryString);
      Object result = query.execute(params);

      if (result instanceof SelectResults) {
        SelectResults<T> selectResults = (SelectResults<T>) result;

View Full Code Here

  private Region<?, ?> simple;

  @Before
  @SuppressWarnings("rawtypes")
  public void setUp() throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
    QueryService queryService = MockRegionFactory.mockQueryService();
    Query singleQuery = mock(Query.class);

    when(singleQuery.execute(any(Object[].class))).thenReturn(0);
    when(queryService.newQuery(SINGLE_QUERY)).thenReturn(singleQuery);

    Query multipleQuery = mock(Query.class);
    SelectResults selectResults = mock(SelectResults.class);

    when(multipleQuery.execute(any(Object[].class))).thenReturn(selectResults);
    when(queryService.newQuery(MULTI_QUERY)).thenReturn(multipleQuery);
  }
View Full Code Here

  @Test
  @SuppressWarnings("unchecked")
  public void testLookupQueryService() {
    ClientCache mockClientCache = mock(ClientCache.class, "testLookupQueryService.ClientCache");
    QueryService mockQueryService = mock(QueryService.class, "testLookupQueryService.QueryService");
    Region<Object, Object> mockRegion = mock(Region.class, "testLookupQueryService.Region");

    when(mockRegion.getRegionService()).thenReturn(mockClientCache);
    when(mockClientCache.getQueryService()).thenReturn(mockQueryService);
View Full Code Here

  @Test
  @SuppressWarnings("unchecked")
  public void testLookupLocalQueryService() {
    ClientCache mockClientCache = mock(ClientCache.class, "testLookupLocalQueryService.ClientCache");
    QueryService mockQueryService = mock(QueryService.class, "testLookupLocalQueryService.QueryService");
    Region<Object, Object> mockRegion = mock(Region.class, "testLookupLocalQueryService.Region");
    RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class, "testLookupLocalQueryService.RegionAttributes");

    when(mockClientCache.getLocalQueryService()).thenReturn(mockQueryService);
    when(mockRegion.getRegionService()).thenReturn(mockClientCache);
View Full Code Here

  /* (non-Javadoc)
   * @see com.gemstone.gemfire.cache.RegionService#getQueryService()
   */
  @Override
  public QueryService getQueryService() {
    QueryService qs = null;
    try {
      qs =  mockQueryService();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

    return gatewayHub;
  }

  QueryService mockQueryService() throws RegionNotFoundException, IndexInvalidException, IndexNameConflictException, IndexExistsException, UnsupportedOperationException {
    QueryService queryService = mock(QueryService.class);

    when(queryService.getIndexes()).thenReturn(new ArrayList<Index>());

    when(queryService.createIndex(anyString(), anyString(),anyString())).thenAnswer(new Answer<Index>() {
      @Override
      public Index answer(InvocationOnMock invocation) throws Throwable {
        String indexName = (String) invocation.getArguments()[0];
        String indexedExpression = (String) invocation.getArguments()[1];
        String fromClause = (String) invocation.getArguments()[2];
        return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.FUNCTIONAL, indexedExpression,
          fromClause, null);
      }
    });

    when(queryService.createIndex(anyString(), anyString(),anyString(),anyString())).thenAnswer(new Answer<Index>() {
      @Override
      public Index answer(InvocationOnMock invocation) throws Throwable {
        String indexName = (String) invocation.getArguments()[0];
        String indexedExpression = (String) invocation.getArguments()[1];
        String fromClause = (String) invocation.getArguments()[2];
        String imports = (String) invocation.getArguments()[3];
        return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.FUNCTIONAL, indexedExpression,
          fromClause, imports);
      }
    });

    when(queryService.createKeyIndex(anyString(), anyString(),anyString())).thenAnswer(new Answer<Index>() {
      @Override
      public Index answer(InvocationOnMock invocation) throws Throwable {
        String indexName = (String) invocation.getArguments()[0];
        String indexedExpression = (String) invocation.getArguments()[1];
        String fromClause = (String) invocation.getArguments()[2];

        return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.PRIMARY_KEY, indexedExpression,
          fromClause, null);
      }
    });

    when(queryService.createHashIndex(anyString(), anyString(),anyString())).thenAnswer(new Answer<Index>() {
      @Override
      public Index answer(InvocationOnMock invocation) throws Throwable {
        String indexName = (String) invocation.getArguments()[0];
        String indexedExpression = (String) invocation.getArguments()[1];
        String fromClause = (String) invocation.getArguments()[2];

        return mockIndex(indexName, com.gemstone.gemfire.cache.query.IndexType.HASH, indexedExpression,
          fromClause, null);
      }
    });

    when(queryService.createHashIndex(anyString(), anyString(),anyString(),anyString())).thenAnswer(new Answer<Index>() {
      @Override
      public Index answer(InvocationOnMock invocation) throws Throwable {
        String indexName = (String) invocation.getArguments()[0];
        String indexedExpression = (String) invocation.getArguments()[1];
        String fromClause = (String) invocation.getArguments()[2];
View Full Code Here

TOP

Related Classes of com.gemstone.gemfire.cache.query.QueryService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.