### Question:
NumberMatcher extends CommonTokensMatcher { @Override public boolean matches(String s1, String s2) { if (s1 == null && s2 == null) return true; String no1 = removeNumbers.transform(s1); String no2 = removeNumbers.transform(s2); if (noNumbersRequireRestMatch && no1.length() == 0 && no2.length() == 0) { return (s1.equals(s2)); } else { return super.matches(no1, no2); } }  @Override int getCost(); @Override boolean matches(String s1, String s2); @Override boolean isExact(); @Override String getExecutionReport(); boolean isNoNumbersRequireRestMatch(); void setNoNumbersRequireRestMatch(boolean noNumbersRequireRestMatch); static int COST; public boolean noNumbersRequireRestMatch; }### Answer:
@Test public void testMatchesExactly () throws Exception { NumberMatcher matcher = new NumberMatcher(); assertTrue(matcher.matches("Abraham Lincoln came 1834 to Ealing, 4 times in a row, riding 23 horses", "Abraham Lincoln came 1934 to Ealing, 4 times in a row, riding 23 horses")); assertTrue(matcher.matches("Abraham Lincoln came 1834 to Ealing, 4 times in a row", "1834 was the year of the goose in Chinese calendar. 4 geese where beatified.")); }
@Test public void noNumbersButRestMatchesExactly () throws Exception { NumberMatcher matcher = new NumberMatcher(); assertTrue(matcher.matches("No numbers at all here!", "No numbers at all here!")); }
@Test public void noNumbersButRestMatchesNotExactly () throws Exception { NumberMatcher matcher = new NumberMatcher(); assertFalse(matcher.matches("No numbers at all here!", "No numbers at all here neither!")); }
@Test public void testMatchesWhitespaceTest () throws Exception { NumberMatcher matcher = new NumberMatcher(); assertFalse(matcher.matches("123", "1 2 3")); assertTrue(matcher.matches("1a2b3", "1 2 3")); }
@Test public void testChangeMinRatio () throws Exception { NumberMatcher matcher = new NumberMatcher(); assertFalse(matcher.matches("1 23", "1 2 3")); matcher.setMinRatio(0.25); assertTrue(matcher.matches("1 23", "1 2 3")); }