### Question:
PatternStemmer implements DbEntityNameStemmer { @Override public String stem(String dbEntityName) { Matcher m = pattern.matcher(dbEntityName); return m.replaceAll(""); } PatternStemmer(String stripPattern, boolean caseSensitive); @Override String stem(String dbEntityName);  }### Answer:
@Test public void testStemNoMatch() { assertEquals("xyzabc", new PatternStemmer("^pre", false).stem("xyzabc")); }
@Test public void testStemCaseSensitive() { assertEquals("PREUPPERCASE", new PatternStemmer("^pre", true).stem("PREUPPERCASE")); assertEquals("UPPERCASE", new PatternStemmer("^pre", true).stem("preUPPERCASE")); }
@Test public void testStemCaseInsensitive() { assertEquals("lowercase", new PatternStemmer("^pre", false).stem("prelowercase")); assertEquals("UPPERCASE", new PatternStemmer("^pre", false).stem("PREUPPERCASE")); }
@Test public void testStemHead() { assertEquals("name", new PatternStemmer("^strip_", false).stem("strip_name")); assertEquals("strip_name", new PatternStemmer("^strip_", false).stem("strip_strip_name")); }
@Test public void testStemTail() { assertEquals("name", new PatternStemmer("_strip$", false).stem("name_strip")); assertEquals("name_strip", new PatternStemmer("_strip$", false).stem("name_strip_strip")); }
@Test public void testStemMiddle() { assertEquals("start_end", new PatternStemmer("_strip", false).stem("start_strip_end")); assertEquals("start_end", new PatternStemmer("_strip", false).stem("start_strip_strip_end")); }