@SuppressWarnings("unchecked")
  private void deserializeQueryResults(DruidSerDe serDe,
                                       String queryType,
                                       String jsonQuery,
                                       byte[] resultString,
                                       Object[][] records)
      throws SerDeException, IOException, NoSuchFieldException, SecurityException, IllegalArgumentException,
      IllegalAccessException, InterruptedException, NoSuchMethodException, InvocationTargetException {

    // Initialize
    HttpClient httpClient = mock(HttpClient.class);
    SettableFuture<InputStream> futureResult = SettableFuture.create();
    futureResult.set(new ByteArrayInputStream(resultString));
    when(httpClient.go(any(), any(HttpResponseHandler.class))).thenReturn(futureResult);
    DruidQueryRecordReader<?> reader = DruidQueryBasedInputFormat.getDruidQueryReader(queryType);

    final HiveDruidSplit split = new HiveDruidSplit(jsonQuery, new Path("empty"), new String[]{"testing_host"});
    Configuration conf = new Configuration();
    reader.initialize(split, DruidStorageHandlerUtils.JSON_MAPPER, DruidStorageHandlerUtils.SMILE_MAPPER, httpClient,
        conf);
    StructObjectInspector oi = (StructObjectInspector) serDe.getObjectInspector();
    List<? extends StructField> fieldRefs = oi.getAllStructFieldRefs();

    // Check mapred
    DruidWritable writable = reader.createValue();
    int pos = 0;
    while (reader.next(NullWritable.get(), writable)) {
      List<Object> row = (List<Object>) serDe.deserialize(writable);
      Object[] expectedFieldsData = records[pos];
      assertEquals(expectedFieldsData.length, fieldRefs.size());
      for (int i = 0; i < fieldRefs.size(); i++) {
        assertEquals("Field " + i + " type", expectedFieldsData[i].getClass(), row.get(i).getClass());
        Object fieldData = oi.getStructFieldData(row, fieldRefs.get(i));
        assertEquals("Field " + i, expectedFieldsData[i], fieldData);
      }
      pos++;
    }
    assertEquals(pos, records.length);

    // Check mapreduce path
    futureResult = SettableFuture.create();
    futureResult.set(new ByteArrayInputStream(resultString));
    when(httpClient.go(any(), any(HttpResponseHandler.class))).thenReturn(futureResult);
    reader = DruidQueryBasedInputFormat.getDruidQueryReader(queryType);
    reader.initialize(split, DruidStorageHandlerUtils.JSON_MAPPER, DruidStorageHandlerUtils.SMILE_MAPPER, httpClient,
        conf);

    pos = 0;
    while (reader.nextKeyValue()) {
      List<Object> row = (List<Object>) serDe.deserialize(reader.getCurrentValue());
      Object[] expectedFieldsData = records[pos];
      assertEquals(expectedFieldsData.length, fieldRefs.size());
      for (int i = 0; i < fieldRefs.size(); i++) {
        assertEquals("Field " + i + " type", expectedFieldsData[i].getClass(), row.get(i).getClass());
        Object fieldData = oi.getStructFieldData(row, fieldRefs.get(i));
        assertEquals("Field " + i, expectedFieldsData[i], fieldData);
      }
      pos++;
    }
    assertEquals(pos, records.length);
  }
Basic tests for Druid SerDe. The examples are taken from Druid 0.9.1.1
documentation.
druid-handler/src/test/org/apache/hadoop/hive/druid/serde/TestDruidSerDe.java