DataPartitioningExporterFactory { public static DataPartitioningExporter getDataPartitioningExporter() { ServiceLoader<DataPartitioningExporter> serviceLoader = ServiceLoader.load(DataPartitioningExporter.class); List<DataPartitioningExporter> dataPartitioningExporters = new ArrayList<>(); for (DataPartitioningExporter dataPartitioningExporter : serviceLoader) { dataPartitioningExporters.add(dataPartitioningExporter); } _logger.info( dataPartitioningExporters.size() + " data partitioning exporters available"); for (DataPartitioningExporter dataPartitioningExporter : dataPartitioningExporters) { _logger.info( "Data partitioning exporter " + dataPartitioningExporter); } if (dataPartitioningExporters.isEmpty() || (dataPartitioningExporters.size() > 1)) { throw new DBProviderNotAvailableException( dataPartitioningExporters.size() + " data partitioning exporters available"); } return dataPartitioningExporters.get(0); }  static DataPartitioningExporter getDataPartitioningExporter();  }
@Test(expected = DBProviderNotAvailableException.class) public void testGetDataPartitioningExporter() throws Exception { DataPartitioningExporterFactory.getDataPartitioningExporter(); }