HandlerFactory { public static ChainResponsibilityHandler createEastAsiaPatternHandler() { ChainResponsibilityHandler handler = new Hiragana(); ChainResponsibilityHandler lastHandler = new KanjiRare(); lastHandler.includeHiragana = true; lastHandler.includeKatakana = true; handler .linkSuccessor(new KatakanaSmall()) .linkSuccessor(new Katakana()) .linkSuccessor(new FullwidthLatinNumbers()) .linkSuccessor(new FullwidthLatinLowercasedLetters()) .linkSuccessor(new FullwidthLatinUppercasedLetters()) .linkSuccessor(new Hangul()) .linkSuccessor(new Kanji()) .linkSuccessor(lastHandler); return handler; } private  HandlerFactory(); static ChainResponsibilityHandler createEastAsiaPatternHandler(); static ChainResponsibilityHandler createLatinPatternHandler();  }
@Test public void createEastAsiaPatternHandler() { ChainResponsibilityHandler chainResponsibilityHandler = HandlerFactory.createEastAsiaPatternHandler(); Assert.assertEquals(chainResponsibilityHandler.handleRequest("ケーキ"), "KKK"); Assert.assertEquals(chainResponsibilityHandler.handleRequest("ほーむ"), "HHH"); Assert.assertEquals(chainResponsibilityHandler.handleRequest("ｰヽヾ"), "kKK"); Assert.assertEquals(chainResponsibilityHandler.handleRequest("ゝゞゟ"), "HHゟ"); Assert.assertEquals(chainResponsibilityHandler.handleRequest("dー"), "dー"); Assert.assertEquals(chainResponsibilityHandler.handleRequest("kー"), "kー"); Assert.assertEquals(chainResponsibilityHandler.handleRequest("Kー"), "KK"); }