MovieFinderFactory { public MovieFinder make(DocumentSourceType documentSourceType) { switch (documentSourceType) { case IMDB_HTML: return new BasicMovieFinder(IMDB_HTML, new IMDBHTMLExchangeStrategy(), config); case OMDB: return new BasicMovieFinder(OMDB, new OMDBExchangeStrategy(config), config); default: throw new IllegalArgumentException("Invalid movie finder type!"); } } @Inject  MovieFinderFactory(Config config); MovieFinder make(DocumentSourceType documentSourceType); MovieFinder make(DocumentSourceType... documentSourceTypes);  }
@Test public void makeSingle() throws Exception { val classMap = new ImmutableMap.Builder<DocumentSourceType, Class<? extends MovieFinder>>() .put(IMDB_HTML, BasicMovieFinder.class) .build(); classMap.forEach((type, clazz) -> { MovieFinder instance = factory.make(type); assertTrue(clazz.isInstance(instance)); assertTrue(instance.getDocumentSourceType().equals(type)); }); }
@Test public void makeMultiple() throws Exception { assertTrue(factory.make(IMDB_HTML) instanceof MixedMovieFinder); }