### Question:
Metaphone implements StringEncoder { public Metaphone() { super(); } Metaphone(); String metaphone(final String txt); @Override Object encode(final Object obj); @Override String encode(final String str); boolean isMetaphoneEqual(final String str1, final String str2); int getMaxCodeLen(); void setMaxCodeLen(final int maxCodeLen);  }### Answer:
@Test public void testMetaphone() { assertEquals("HL", this.getStringEncoder().metaphone("howl")); assertEquals("TSTN", this.getStringEncoder().metaphone("testing")); assertEquals("0", this.getStringEncoder().metaphone("The")); assertEquals("KK", this.getStringEncoder().metaphone("quick")); assertEquals("BRN", this.getStringEncoder().metaphone("brown")); assertEquals("FKS", this.getStringEncoder().metaphone("fox")); assertEquals("JMPT", this.getStringEncoder().metaphone("jumped")); assertEquals("OFR", this.getStringEncoder().metaphone("over")); assertEquals("0", this.getStringEncoder().metaphone("the")); assertEquals("LS", this.getStringEncoder().metaphone("lazy")); assertEquals("TKS", this.getStringEncoder().metaphone("dogs")); }
@Test public void testWordEndingInMB() { assertEquals( "KM", this.getStringEncoder().metaphone("COMB") ); assertEquals( "TM", this.getStringEncoder().metaphone("TOMB") ); assertEquals( "WM", this.getStringEncoder().metaphone("WOMB") ); }
@Test public void testDiscardOfSCEOrSCIOrSCY() { assertEquals( "SNS", this.getStringEncoder().metaphone("SCIENCE") ); assertEquals( "SN", this.getStringEncoder().metaphone("SCENE") ); assertEquals( "S", this.getStringEncoder().metaphone("SCY") ); }
@Test public void testWhy() { assertEquals("", this.getStringEncoder().metaphone("WHY")); }
@Test public void testWordsWithCIA() { assertEquals( "XP", this.getStringEncoder().metaphone("CIAPO") ); }
@Test public void testTranslateOfSCHAndCH() { assertEquals( "SKTL", this.getStringEncoder().metaphone("SCHEDULE") ); assertEquals( "SKMT", this.getStringEncoder().metaphone("SCHEMATIC") ); assertEquals( "KRKT", this.getStringEncoder().metaphone("CHARACTER") ); assertEquals( "TX", this.getStringEncoder().metaphone("TEACH") ); }
@Test public void testTranslateToJOfDGEOrDGIOrDGY() { assertEquals( "TJ", this.getStringEncoder().metaphone("DODGY") ); assertEquals( "TJ", this.getStringEncoder().metaphone("DODGE") ); assertEquals( "AJMT", this.getStringEncoder().metaphone("ADGIEMTI") ); }
@Test public void testDiscardOfSilentHAfterG() { assertEquals( "KNT", this.getStringEncoder().metaphone("GHENT") ); assertEquals( "B", this.getStringEncoder().metaphone("BAUGH") ); }
@Test public void testDiscardOfSilentGN() { assertEquals( "N", this.getStringEncoder().metaphone("GNU") ); assertEquals( "SNT", this.getStringEncoder().metaphone("SIGNED") ); }
@Test public void testPHTOF() { assertEquals( "FX", this.getStringEncoder().metaphone("PHISH") ); }
@Test public void testSHAndSIOAndSIAToX() { assertEquals( "XT", this.getStringEncoder().metaphone("SHOT") ); assertEquals( "OTXN", this.getStringEncoder().metaphone("ODSIAN") ); assertEquals( "PLXN", this.getStringEncoder().metaphone("PULSION") ); }
@Test public void testTIOAndTIAToX() { assertEquals( "OX", this.getStringEncoder().metaphone("OTIA") ); assertEquals( "PRXN", this.getStringEncoder().metaphone("PORTION") ); }
@Test public void testTCH() { assertEquals( "RX", this.getStringEncoder().metaphone("RETCH") ); assertEquals( "WX", this.getStringEncoder().metaphone("WATCH") ); }
@Test public void testExceedLength() { assertEquals( "AKSK", this.getStringEncoder().metaphone("AXEAXE") ); }