ImporterFactoryLoader { public ImporterFactory getImporterFactory(final InputFile file) { final List<ImporterFactory> matchingImporters = getMatchingFactories(file); switch (matchingImporters.size()) { case 0: throw new ImporterException("Found no matching importer for file '" + file + "'"); case 1: return matchingImporters.get(0); default: throw new ImporterException( "Found more than one matching importer for file '" + file + "'"); } } ImporterFactoryLoader(
            final InitializingServiceLoader<ImporterFactory, ImporterContext> serviceLoader); ImporterFactory getImporterFactory(final InputFile file); boolean supportsFile(final InputFile file);  }
@Test void testNoFactoryRegisteredThrowsException() { simulateFactories(); assertThrows(ImporterException.class, () -> this.loader.getImporterFactory(this.file)); }
@Test void testMultipleMatchingFactoriesFoundThrowsException() { simulateFactories(this.supportedFactory1, this.supportedFactory1); assertThrows(ImporterException.class, () -> this.loader.getImporterFactory(this.file)); }