@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); for (Keyboard keyboard : keyboards) { extend(matches, spatialMatchHelper(password, keyboard)); } return this.sorted(matches); }
@Test public void testSpatialMatching() throws Exception { String msg = "doesn't match 1- and 2-character spatial patterns"; assertEquals(msg, 0, new SpatialMatcher().execute(password).size()); }
@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 testSpatialMatching() throws Exception { final Keyboard keyboard = Keyboard.QWERTY; final String token = "6tfGHJ"; List<Match> actualMatches = new SpatialMatcher(Collections.singletonList(keyboard)) .execute("rz!" + token + "%z"); String msg = "matches against spatial patterns surrounded by non-spatial patterns"; ExpectedMatch[] expectedMatches = new ExpectedMatch[]{ new ExpectedMatch(token, 3, 3 + token.length() - 1).graph(keyboard.getName()).turns(2).shiftedCount(3) }; assertMatches(msg, Pattern.Spatial, 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); } }
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); for (Keyboard keyboard : keyboards) { extend(matches, spatialMatchHelper(password, keyboard)); } return this.sorted(matches); }
@Test public void testSpatialMatching() throws Exception { List<Match> actualMatches = new SpatialMatcher(Collections.singletonList(keyboard)).execute(token); String msg = String.format("matches %s as a %s token", token, keyboard); assertMatches(msg, Pattern.Spatial, new ExpectedMatch[]{ new ExpectedMatch(token).graph(keyboard.getName()).turns(turns).shiftedCount(shifts)}, actualMatches); }