PatternMatcher { public static boolean matchCharDatePattern(String value, String pattern) { if (value == null) return false; Set<String> patterns = new HashSet<>(); for (AbstractPatternRecognizer patternRecognizer : patternRecognizerList) patterns.addAll(patternRecognizer.getValuePattern(value)); if (!isDatePattern(pattern) && containsDatePattern(patterns)) return false; return patterns.contains(pattern); } private  PatternMatcher(); static boolean matchCharDatePattern(String value, String pattern); static boolean matchWordPattern(String value, String pattern); static boolean matchWordPattern(String value, String pattern, boolean caseSensitive);  }
@Test public void matcherPatternDateDayFirst() { Assert.assertTrue(PatternMatcher.matchCharDatePattern("08/08/2018", "dd/MM/yyyy")); }
@Test public void matcherPatternDateMonthFirst() { String input = "08/08/2018"; Assert.assertFalse(PatternMatcher.matchCharDatePattern(input, "99/99/9999")); Assert.assertFalse(PatternMatcher.matchCharDatePattern(input, "yyyy/MM/dd")); Assert.assertTrue(PatternMatcher.matchCharDatePattern(input, "MM/dd/yyyy")); }
@Test public void matcherPatternNotDate() { Assert.assertTrue(PatternMatcher.matchCharDatePattern("32/13/2018", "99/99/9999")); Assert.assertFalse(PatternMatcher.matchCharDatePattern("32/13/2018", "dd/MM/yyyy")); }
@Test public void matcherPatternName() { Assert.assertTrue(PatternMatcher.matchCharDatePattern("Toronto", "Aaaaaaa")); }
@Test public void matcherPatternEmpty() { Assert.assertTrue(PatternMatcher.matchCharDatePattern("", "")); Assert.assertFalse(PatternMatcher.matchCharDatePattern("", "9")); }
@Test public void matcherPatternNull() { Assert.assertFalse(PatternMatcher.matchCharDatePattern(null, "whatEver")); }
@Test public void matcherPatternNameWithNumber() { Assert.assertTrue(PatternMatcher.matchCharDatePattern("Toronto1234", "Aaaaaaa9999")); }