@Test public void testSequenceMatching() throws Exception { String msg = String.format("doesn't match length-%s sequences", password.length()); assertEquals(msg, new SequenceMatcher().execute(password).size(), 0); }
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); List<Matcher> matchers = new ArrayList<>(); matchers.add(new DictionaryMatcher(dictionaries)); matchers.add(new ReverseDictionaryMatcher(dictionaries)); matchers.add(new L33tMatcher(dictionaries)); matchers.add(new SpatialMatcher()); matchers.add(new RepeatMatcher()); matchers.add(new SequenceMatcher()); matchers.add(new RegexMatcher()); matchers.add(new DateMatcher()); for (Matcher matcher: matchers) matches.addAll(matcher.execute(password)); return this.sorted(matches); } }
@Test public void testSequenceMatching() throws Exception { List<Match> actualMatches = new SequenceMatcher().execute("abcbabc"); ExpectedMatch[] expectedMatches = new ExpectedMatch[]{ new ExpectedMatch("abc", 0, 2).ascending(true), new ExpectedMatch("cba", 2, 4).ascending(false), new ExpectedMatch("abc", 4, 6).ascending(true) }; assertMatches("matches overlapping patterns", Pattern.Sequence, expectedMatches, actualMatches); }
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); List<Matcher> matchers = new ArrayList<>(); matchers.add(new DictionaryMatcher(dictionaries)); matchers.add(new ReverseDictionaryMatcher(dictionaries)); matchers.add(new L33tMatcher(dictionaries)); matchers.add(new SpatialMatcher()); matchers.add(new RepeatMatcher()); matchers.add(new SequenceMatcher()); matchers.add(new RegexMatcher()); matchers.add(new DateMatcher()); for (Matcher matcher: matchers) matches.addAll(matcher.execute(password)); return this.sorted(matches); } }