private List<DataSegment> getUsedSegmentsList(DerbyConnectorTestUtility connector,
      final MetadataStorageTablesConfig metadataStorageTablesConfig) {
    return connector.getDBI()
        .withHandle(handle -> handle.createQuery(String.format(
            "SELECT payload FROM %s WHERE used=true ORDER BY created_date ASC",
            metadataStorageTablesConfig.getSegmentsTable()))
            .map((i, resultSet, statementContext) -> {
              try {
                return DruidStorageHandlerUtils.JSON_MAPPER.readValue(resultSet.getBytes("payload"), DataSegment.class);
              } catch (IOException e) {
                throw Throwables.propagate(e);
              }
            }).list());
  }
Test class for Druid Storage handler.
druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidStorageHandler.java