MovieParser extends ContentParser<Movie> { @Override public Movie parse(String input) { Matcher matcher = mainPattern.matcher(input); if(matcher.matches()){ String name = getName(matcher.group(1)); Integer year = Integer.valueOf(matcher.group(2)); Quality qualityEnum = Quality.STANDARD; matcher = qualityPattern.matcher(input); if(matcher.find()){ String quality = matcher.group(); if(quality.equals(QUALITY_HD)) qualityEnum = Quality.HD; else if(quality.equals(QUALITY_FULLHD)) qualityEnum = Quality.FULLHD; } return new Movie(name, year, qualityEnum); } else { return null; } }  @Override Movie parse(String input);  }
@Test public void shouldReturnMovieWhenParseMovieTypeOfInput1() throws MalformedURLException { String movieInput = "Oz the Great and Powerful 2013 1080p BluRay DTS-HDMA 7 1 x264-LEGi0N"; assertEquals(getExpectedMovie(), movieParser.parse(getMatchItem(movieInput))); }
@Test public void shouldReturnMovieWhenParseMovieInputWithDots() throws MalformedURLException { String movieInput = "Oz.the.Great.and.Powerful.2013.1080p.BluRay.DTS-HDMA.7.1.x264-LEGi0N"; assertEquals(getExpectedMovie(), movieParser.parse(getMatchItem(movieInput))); }