예제 #1
0
    /**
     * Parses a JSON dataset input stream and returns the list of DBUnit tables contained in that
     * input stream
     *
     * @param iStream A JSON dataset input stream
     * @return A list of DBUnit tables
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<ITable> getTables(InputStream iStream) {
      List<ITable> tables = new ArrayList<ITable>();

      try {
        // get the base object tree from the JSON stream
        Map<String, Object> dataset = mapper.readValue(iStream, Map.class);
        // iterate over the tables in the object tree
        for (Map.Entry<String, Object> entry : dataset.entrySet()) {
          // get the rows for the table
          List<Map<String, Object>> rows = (List<Map<String, Object>>) entry.getValue();
          ITable table = processTable(entry.getKey(), rows);
          // add the table to the list of DBUnit tables
          tables.add(table);
        }

      } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
      }
      return tables;
    }
예제 #2
0
 @Override
 protected ITableIterator createIterator(boolean reverse) throws DataSetException {
   return new DefaultTableIterator(tables.toArray(new ITable[tables.size()]));
 }