RestSQLQueryAction extends BaseRestHandler { @Override protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient nodeClient) { throw new UnsupportedOperationException("New SQL handler is not ready yet"); } RestSQLQueryAction(ClusterService clusterService, Settings pluginSettings); @Override String getName(); @Override List<Route> routes(); RestChannelConsumer prepareRequest(SQLQueryRequest request, NodeClient nodeClient); static final RestChannelConsumer NOT_SUPPORTED_YET; }
@Test public void handleQueryThatCanSupport() { SQLQueryRequest request = new SQLQueryRequest( new JSONObject("{\"query\": \"SELECT -123\"}"), "SELECT -123", QUERY_API_ENDPOINT, ""); RestSQLQueryAction queryAction = new RestSQLQueryAction(clusterService, settings); assertNotSame(NOT_SUPPORTED_YET, queryAction.prepareRequest(request, nodeClient)); }
@Test public void skipExplainThatNotSupport() { SQLQueryRequest request = new SQLQueryRequest( new JSONObject("{\"query\": \"SELECT * FROM test\"}"), "SELECT * FROM test", EXPLAIN_API_ENDPOINT, ""); RestSQLQueryAction queryAction = new RestSQLQueryAction(clusterService, settings); assertSame(NOT_SUPPORTED_YET, queryAction.prepareRequest(request, nodeClient)); }
@Test public void skipQueryThatNotSupport() { SQLQueryRequest request = new SQLQueryRequest( new JSONObject("{\"query\": \"SELECT * FROM test WHERE age = 10 GROUP BY age LIMIT 10\"}"), "SELECT * FROM test WHERE age = 10 GROUP BY age LIMIT 10", QUERY_API_ENDPOINT, ""); RestSQLQueryAction queryAction = new RestSQLQueryAction(clusterService, settings); assertSame(NOT_SUPPORTED_YET, queryAction.prepareRequest(request, nodeClient)); }