@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup mView = (ViewGroup) inflater.inflate(R.layout.fragment_main, container, false); btnFetch = (Button) mView.findViewById(R.id.btnSearch); txtSearch = (EditText) mView.findViewById(R.id.txtSearch); btnFetch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JsonHandler handler = new JsonHandler(); handler.fetchImages(txtSearch.getText().toString()); } }); return mView; }
public AvaticaJsonHandler(Service service, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.service = Objects.requireNonNull(service); this.metrics = Objects.requireNonNull(metrics); // Avatica doesn't have a Guava dependency this.jsonHandler = new JsonHandler(service, this.metrics); // Metrics this.requestTimer = this.metrics.getTimer( concat(AvaticaJsonHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.threadLocalBuffer = new ThreadLocal<UnsynchronizedBuffer>() { @Override public UnsynchronizedBuffer initialValue() { return new UnsynchronizedBuffer(); } }; this.serverConfig = serverConfig; }
public AvaticaJsonHandler(Service service, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.service = Objects.requireNonNull(service); this.metrics = Objects.requireNonNull(metrics); // Avatica doesn't have a Guava dependency this.jsonHandler = new JsonHandler(service, this.metrics); // Metrics this.requestTimer = this.metrics.getTimer( concat(AvaticaJsonHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.threadLocalBuffer = new ThreadLocal<UnsynchronizedBuffer>() { @Override public UnsynchronizedBuffer initialValue() { return new UnsynchronizedBuffer(); } }; this.serverConfig = serverConfig; }
@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); 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))); } }
@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))); } }
@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))); } }