@ParameterizedTest @ArgumentsSource(TestCaseArgumentsProvider.class) @NullValue("NULL") @TestCase({"NULL", "NULL", "BOB", ",,", ",,", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "Bob", ",,", ",,", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "bob", ",,", ",,", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "BOB", ",,", ",,", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "Bob", ",,", ",,", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "bob", ",,", ",,", "fred,bob,joe", "true"}) @TestCase({"", "NULL", "BOB", ",,", ",,", "FRED,BOB,JOE", "true"}) @TestCase({"", "NULL", "Bob", ",,", ",,", "FRED,BOB,JOE", "true"}) @TestCase({"", "NULL", "bob", ",,", ",,", "FRED,BOB,JOE", "true"}) @TestCase({"", "NULL", "BOB", ",,", ",,", "fred,bob,joe", "true"}) @TestCase({"", "NULL", "Bob", ",,", ",,", "fred,bob,joe", "true"}) @TestCase({"", "NULL", "bob", ",,", ",,", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "BOB", "NULL,NULL,NULL", "NULL,NULL,NULL", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "Bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "BOB", "NULL,NULL,NULL", "NULL,NULL,NULL", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "Bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "BOB", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "Bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "NULL", "BOB", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "Bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"NULL", "S2", "BOB", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "S2", "Bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "S2", "bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"NULL", "s2", "BOB", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"NULL", "s2", "Bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"NULL", "s2", "bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"C2", "NULL", "BOB", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"C2", "NULL", "Bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"C2", "NULL", "bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"c2", "NULL", "BOB", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"c2", "NULL", "Bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"c2", "NULL", "bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"C2", "S2", "BOB", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"C2", "S2", "Bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"C2", "S2", "bob", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "true"}) @TestCase({"c2", "s2", "BOB", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"c2", "s2", "Bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"c2", "s2", "bob", "C1,C2,C3", "S1,S2,S3", "fred,bob,joe", "true"}) @TestCase({"C2", "S2", "BOB", "NULL,NULL,NULL", "NULL,NULL,NULL", "FRED,BOB,JOE", "true"}) @TestCase({"C2", "S2", "Bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "FRED,BOB,JOE", "true"}) @TestCase({"C2", "S2", "bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "FRED,BOB,JOE", "true"}) @TestCase({"c2", "s2", "BOB", "NULL,NULL,NULL", "NULL,NULL,NULL", "fred,bob,joe", "true"}) @TestCase({"c2", "s2", "Bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "fred,bob,joe", "true"}) @TestCase({"c2", "s2", "bob", "NULL,NULL,NULL", "NULL,NULL,NULL", "fred,bob,joe", "true"}) @TestCase({"NULL", "NULL", "BOBBY", ",,", ",,", "FRED,BOB,JOE", "false"}) @TestCase({"NULL", "SX", "BOB", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "false"}) @TestCase({"CX", "NULL", "BOB", "C1,C2,C3", "S1,S2,S3", "FRED,BOB,JOE", "false"}) void tableExists(String catalog, String schema, String tableName, String[] actualCatalog, String[] actualSchema, String[] actualTable, boolean exists) throws SQLException { when(metaData.getTables(isNull(), isNull(), isNull(), eq(new String[] {"TABLE"}))) .thenReturn(resultSet); when(resultSet.getString("TABLE_CAT")) .thenReturn(actualCatalog); when(resultSet.getString("TABLE_SCHEM")) .thenReturn(actualSchema); when(resultSet.getString("TABLE_NAME")) .thenReturn(actualTable); when(resultSet.next()) .thenReturn(actualTable.length, TRUE) .thenReturn(FALSE); boolean result = DatabaseMetaDataUtil.tableExists(metaData, catalog, schema, tableName); verify(metaData).getTables(isNull(), isNull(), isNull(), eq(new String[] {"TABLE"})); assertThat(result, is(exists)); }
public static boolean tableExists(DatabaseMetaData metaData, String catalog, String schema, String tableName) { return tableNames(metaData, catalog, schema) .anyMatch(matchesName(tableName)); }
DatabaseMetaDataUtil extends UtilityClass { public static boolean tableExists(DatabaseMetaData metaData, String catalog, String schema, String tableName) { return tableNames(metaData, catalog, schema) .anyMatch(matchesName(tableName)); } }
DatabaseMetaDataUtil extends UtilityClass { public static boolean tableExists(DatabaseMetaData metaData, String catalog, String schema, String tableName) { return tableNames(metaData, catalog, schema) .anyMatch(matchesName(tableName)); }  }
DatabaseMetaDataUtil extends UtilityClass { public static boolean tableExists(DatabaseMetaData metaData, String catalog, String schema, String tableName) { return tableNames(metaData, catalog, schema) .anyMatch(matchesName(tableName)); }  static boolean tableExists(DatabaseMetaData metaData, String catalog, String schema, String tableName); static Stream<QualifiedName> tableNames(DatabaseMetaData metaData, String catalog, String schema); static Stream<ForeignKeyName> foreignKeyNames(DatabaseMetaData metaData, String catalog, String schema); }
DatabaseMetaDataUtil extends UtilityClass { public static boolean tableExists(DatabaseMetaData metaData, String catalog, String schema, String tableName) { return tableNames(metaData, catalog, schema) .anyMatch(matchesName(tableName)); }  static boolean tableExists(DatabaseMetaData metaData, String catalog, String schema, String tableName); static Stream<QualifiedName> tableNames(DatabaseMetaData metaData, String catalog, String schema); static Stream<ForeignKeyName> foreignKeyNames(DatabaseMetaData metaData, String catalog, String schema);  }