MovieParsers { public static MovieParser ofSourceType(DocumentSourceType documentSourceType) { switch (documentSourceType) { case IMDB_HTML: return new IMDBHTMLMovieParser(); case OMDB: return new OMDBMovieParser(); default: throw new IllegalArgumentException("Unsupported format!"); } } private  MovieParsers(); static MovieParser ofSourceType(DocumentSourceType documentSourceType); static MovieParser fileParser();  }
@Test public void ofSourceType() throws Exception { val classMap = new ImmutableMap.Builder<DocumentSourceType, Class<? extends MovieParser>>() .put(IMDB_HTML, IMDBHTMLMovieParser.class) .build(); classMap.forEach((format, clazz) -> { MovieParser instance = MovieParsers.ofSourceType(format); assertTrue(clazz.isInstance(instance)); }); }