Search in sources :

Example 1 with JsonHandler

use of org.apache.calcite.avatica.remote.JsonHandler in project calcite-avatica by apache.

the class JsonHandlerTest method testExecuteRequestWithNumberParameter.

@Test
public void testExecuteRequestWithNumberParameter() {
    final List<TypedValue> expectedParameterValues = new ArrayList<>();
    final Service service = new ParameterValuesCheckingService(expectedParameterValues);
    final JsonService jsonService = new LocalJsonService(service);
    final JsonHandler jsonHandler = new JsonHandler(jsonService, NoopMetricsSystem.getInstance());
    final List<TypedValue> parameterValues = Arrays.asList(TypedValue.create("NUMBER", new BigDecimal("123")), TypedValue.create("STRING", "calcite"));
    jsonHandler.apply("{'request':'execute'," + "'parameterValues':[{'type':'NUMBER','value':123}," + "{'type':'STRING','value':'calcite'}]}");
    assertThat(expectedParameterValues.size(), is(2));
    assertThat(expectedParameterValues.get(0), is(parameterValues.get(0)));
    assertThat(expectedParameterValues.get(1), is(parameterValues.get(1)));
}
Also used : LocalJsonService(org.apache.calcite.avatica.remote.LocalJsonService) ArrayList(java.util.ArrayList) JsonHandler(org.apache.calcite.avatica.remote.JsonHandler) JsonService(org.apache.calcite.avatica.remote.JsonService) Service(org.apache.calcite.avatica.remote.Service) LocalJsonService(org.apache.calcite.avatica.remote.LocalJsonService) JsonService(org.apache.calcite.avatica.remote.JsonService) LocalJsonService(org.apache.calcite.avatica.remote.LocalJsonService) BigDecimal(java.math.BigDecimal) TypedValue(org.apache.calcite.avatica.remote.TypedValue) Test(org.junit.Test)

Aggregations

BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 JsonHandler (org.apache.calcite.avatica.remote.JsonHandler)1 JsonService (org.apache.calcite.avatica.remote.JsonService)1 LocalJsonService (org.apache.calcite.avatica.remote.LocalJsonService)1 Service (org.apache.calcite.avatica.remote.Service)1 TypedValue (org.apache.calcite.avatica.remote.TypedValue)1 Test (org.junit.Test)1