test_class.declarator: CATALOG = "test"
test_class.modifier: private static final
test_class.original_string: private static final String CATALOG = "test";
test_class.type: String
test_class.var_name: CATALOG
test_class.declarator: connection
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Connection connection;
test_class.type: Connection
test_class.var_name: connection
test_class.declarator: preparedStatement
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private PreparedStatement preparedStatement;
test_class.type: PreparedStatement
test_class.var_name: preparedStatement
test_class.declarator: resultSet
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ResultSet resultSet;
test_class.type: ResultSet
test_class.var_name: resultSet
test_class.declarator: metaData
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DatabaseMetaData metaData;
test_class.type: DatabaseMetaData
test_class.var_name: metaData
test_class.declarator: dataSources
test_class.modifier: private
test_class.original_string: private Collection<DataSource> dataSources;
test_class.type: Collection<DataSource>
test_class.var_name: dataSources
test_class.file: shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java
test_class.identifier: PostgreSQLDataSourceCheckerTest
test_case.body: @Test(expected = PrepareFailedException.class)
      public void assertCheckPrivilegeFailure() throws SQLException {
          when(resultSet.next()).thenReturn(true);
          when(resultSet.getString(3)).thenReturn("test");
          when(connection.prepareStatement("SELECT * FROM test LIMIT 1")).thenThrow(new SQLException(""));
          PostgreSQLDataSourceChecker dataSourceChecker = new PostgreSQLDataSourceChecker();
          dataSourceChecker.checkPrivilege(dataSources);
      }
test_case.class_method_signature: PostgreSQLDataSourceCheckerTest.assertCheckPrivilegeFailure()
test_case.full_signature: @Test(expected = PrepareFailedException.class) public void assertCheckPrivilegeFailure()
test_case.identifier: assertCheckPrivilegeFailure
test_case.invocations: thenReturn when next thenReturn when getString thenThrow when prepareStatement checkPrivilege
test_case.modifiers: @Test(expected = PrepareFailedException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void assertCheckPrivilegeFailure()
focal_class.file: shardingsphere-scaling/shardingsphere-scaling-postgresql/src/main/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceChecker.java
focal_class.identifier: PostgreSQLDataSourceChecker
focal_class.class_method_signature: PostgreSQLDataSourceChecker.checkPrivilege(final Collection<? extends DataSource> dataSources)
focal_class.full_signature: @Override public void checkPrivilege(final Collection<? extends DataSource> dataSources)
focal_class.identifier: checkPrivilege
focal_class.modifiers: @Override public
focal_class.parameters: (final Collection<? extends DataSource> dataSources)
focal_class.return: void
focal_class.signature: void checkPrivilege(final Collection<? extends DataSource> dataSources)
focal_class.class_method_signature: PostgreSQLDataSourceChecker.checkVariable(final Collection<? extends DataSource> dataSources)
focal_class.full_signature: @Override public void checkVariable(final Collection<? extends DataSource> dataSources)
focal_class.identifier: checkVariable
focal_class.modifiers: @Override public
focal_class.parameters: (final Collection<? extends DataSource> dataSources)
focal_class.return: void
focal_class.signature: void checkVariable(final Collection<? extends DataSource> dataSources)
focal_class.superclass: extends AbstractDataSourceChecker
focal_method.body: @Override
      public void checkPrivilege(final Collection<? extends DataSource> dataSources) {
          try {
              for (DataSource dataSource : dataSources) {
                  String tableName;
                  try (Connection connection = dataSource.getConnection()) {
                      ResultSet tables = connection.getMetaData().getTables(connection.getCatalog(), null, "%", new String[]{"TABLE"});
                      if (tables.next()) {
                          tableName = tables.getString(3);
                      } else {
                          throw new PrepareFailedException("No tables find in the source data source");
                      }
                      connection.prepareStatement(String.format("SELECT * FROM %s LIMIT 1", tableName)).executeQuery();
                  }
              }
          } catch (final SQLException ex) {
              throw new PrepareFailedException("Data sources privilege check failed!", ex);
          }
      }
focal_method.class_method_signature: PostgreSQLDataSourceChecker.checkPrivilege(final Collection<? extends DataSource> dataSources)
focal_method.full_signature: @Override public void checkPrivilege(final Collection<? extends DataSource> dataSources)
focal_method.identifier: checkPrivilege
focal_method.invocations: getConnection getTables getMetaData getCatalog next getString executeQuery prepareStatement format
focal_method.modifiers: @Override public
focal_method.parameters: (final Collection<? extends DataSource> dataSources)
focal_method.return: void
focal_method.signature: void checkPrivilege(final Collection<? extends DataSource> dataSources)