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];