public RowMetaInterface getQueryFieldsFromDatabaseMetaData() throws Exception {
    return this.getQueryFieldsFromDatabaseMetaData( null );
  }
@Test
  public void testGetQueryFieldsFromDatabaseMetaData() throws Exception {
    DatabaseMeta meta = mock( DatabaseMeta.class );
    DatabaseMetaData dbMetaData = mock( DatabaseMetaData.class );
    Connection conn = mockConnection( dbMetaData );
    ResultSet rs = mock( ResultSet.class );
    String columnName = "year";
    String columnType = "Integer";
    int columnSize = 15;

    when( dbMetaData.getColumns( anyString(), anyString(), or( anyString(), eq( null ) ), or( anyString(), eq( null ) ) ) ).thenReturn( rs );
    when( rs.next() ).thenReturn( true ).thenReturn( false );
    when( rs.getString( "COLUMN_NAME" ) ).thenReturn( columnName );
    when( rs.getString( "SOURCE_DATA_TYPE" ) ).thenReturn( columnType );
    when( rs.getInt( "COLUMN_SIZE" ) ).thenReturn( columnSize );

    Database db = new Database( log, meta );
    db.setConnection( conn );
    RowMetaInterface rowMetaInterface = db.getQueryFieldsFromDatabaseMetaData();

    assertEquals( rowMetaInterface.size(), 1 );
    assertEquals( rowMetaInterface.getValueMeta( 0 ).getName(), columnName );
    assertEquals( rowMetaInterface.getValueMeta( 0 ).getOriginalColumnTypeName(), columnType );
    assertEquals( rowMetaInterface.getValueMeta( 0 ).getLength(), columnSize );
  }