private void getTablesTest(Set<String> tableTypeNames, String viewTypeName) throws SQLException {
    String[] ALL = null;
    String[] VIEW_ONLY = { viewTypeName };
    String[] TABLE_ONLY = tableTypeNames.toArray(new String[tableTypeNames.size()]);

    Set<String> viewOrTableArray = new HashSet<String>();
    viewOrTableArray.addAll(tableTypeNames);
    viewOrTableArray.add(viewTypeName);
    String testTblWithDb = StatsUtils.getFullyQualifiedTableName(testDbName, tableName);
    String testPartTblWithDb = StatsUtils.getFullyQualifiedTableName(testDbName, partitionedTableName);
    String testDataTypeTblWithDb = StatsUtils.getFullyQualifiedTableName(testDbName, dataTypeTableName);
    String testViewWithDb = StatsUtils.getFullyQualifiedTableName(testDbName, viewName);
    String testExtTblWithDb = StatsUtils.getFullyQualifiedTableName(testDbName, externalTableName);

    Map<Object[], String[]> tests = new IdentityHashMap<Object[], String[]>();
    tests.put(new Object[] { null, "testjdbc%", ALL }, new String[] { testTblWithDb,
        testPartTblWithDb, testViewWithDb, testExtTblWithDb, testDataTypeTblWithDb });
    tests.put(new Object[] { "test%", "testjdbc%", ALL }, new String[] { testTblWithDb,
        testPartTblWithDb, testViewWithDb, testExtTblWithDb, testDataTypeTblWithDb });
    tests.put(new Object[] { "test%", "testjdbc%", VIEW_ONLY }, new String[] { testViewWithDb });
    tests.put(new Object[] { null, "testjdbcdrivertbl", ALL }, new String[] { testTblWithDb });
    tests.put(new Object[] { "%jdbc%", "testjdbcdrivertbl", ALL }, new String[] { testTblWithDb });
    tests.put(new Object[] { "%jdbc%", "testjdbc%", ALL }, new String[] { testTblWithDb,
        testPartTblWithDb, testViewWithDb, testExtTblWithDb, testDataTypeTblWithDb });
    tests.put(new Object[] { "%jdbc%", "testjdbcdrivertbl", TABLE_ONLY },
        new String[] { testTblWithDb });
    tests.put(new Object[] { null, "test_dbcdri_ertbl", ALL }, new String[] { testTblWithDb });
    tests.put(new Object[] { null, "%jdbc%", ALL }, new String[] { testTblWithDb,
        testPartTblWithDb, testViewWithDb, testDataTypeTblWithDb, testExtTblWithDb });
    tests.put(new Object[] { "%", "%jdbc%", VIEW_ONLY }, new String[] { testViewWithDb });
    tests.put(new Object[] { null, "%jdbc%", TABLE_ONLY }, new String[] { testTblWithDb,
        testPartTblWithDb, testExtTblWithDb, testDataTypeTblWithDb });

    for (Map.Entry<Object[], String[]> entry : tests.entrySet()) {
      Object[] checkPattern = entry.getKey();
      String debugString =
          checkPattern[0] + ", " + checkPattern[1] + ", "
              + Arrays.toString((String[]) checkPattern[2]);

      Set<String> expectedTables = new HashSet<String>(Arrays.asList(entry.getValue()));
      ResultSet rs =
          con.getMetaData().getTables(null, (String) checkPattern[0], (String) checkPattern[1],
              (String[]) checkPattern[2]);
      ResultSetMetaData resMeta = rs.getMetaData();
      assertEquals(10, resMeta.getColumnCount());
      assertEquals("TABLE_CAT", resMeta.getColumnName(1));
      assertEquals("TABLE_SCHEM", resMeta.getColumnName(2));
      assertEquals("TABLE_NAME", resMeta.getColumnName(3));
      assertEquals("TABLE_TYPE", resMeta.getColumnName(4));
      assertEquals("REMARKS", resMeta.getColumnName(5));

      int cnt = 0;
      while (rs.next()) {
        String resultDbName = rs.getString("TABLE_SCHEM");
        String resultTableName = rs.getString("TABLE_NAME");
        String fullTableName = StatsUtils.getFullyQualifiedTableName(resultDbName, resultTableName);
        assertTrue("Invalid table " + fullTableName + " for test " + debugString,
            expectedTables.contains(fullTableName));

        String resultTableComment = rs.getString("REMARKS");
        assertTrue("Missing comment on the table.", resultTableComment.length() > 0);
        String tableType = rs.getString("TABLE_TYPE");
        if (resultTableName.endsWith("view")) {
          assertEquals("Expected a tabletype view but got something else.", viewTypeName, tableType);
        } else {
          assertTrue("Expected one of " + tableTypeNames + " table but got something else: "
              + tableType, tableTypeNames.contains(tableType));
        }
        cnt++;
      }
      rs.close();
      assertEquals("Received an incorrect number of tables for test " + debugString,
          expectedTables.size(), cnt);
    }
  }
Test the type returned for pre-created table type table and view type table
@param tableTypeNames expected table types
@param viewTypeName expected view type
@throws SQLException
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java