CRCRHandler extends AbstractChainOfResponsibilityHandler { @Override public AbstractChainOfResponsibilityHandler linkSuccessor(AbstractChainOfResponsibilityHandler nextHandler) { if (nextHandler instanceof CRCRHandler) { return super.linkSuccessor(nextHandler); } else { return this; } } CRCRHandler(HandlerParameter handlerParameter); @Override void handleRequest(Object inputData, int rowNum); @Override void handleRequest(); @Override CRCRHandler getSuccessor(); @Override AbstractChainOfResponsibilityHandler linkSuccessor(AbstractChainOfResponsibilityHandler nextHandler); SurvivedResult getSurvivedRowNum(); boolean isValidResult(); Object getLongestResult(Object result); Object getNonDuplicatedResult(Object result); boolean isMissionCompleted();  }
@Test public void testLinkSuccessor() { HandlerParameter createHandlerParameter = this.createHandlerParameter(null); AbstractChainOfResponsibilityHandler crcr1 = new CRCRHandler(createHandlerParameter); AbstractChainOfResponsibilityHandler crcr2 = new CRCRHandler(createHandlerParameter); AbstractChainOfResponsibilityHandler mtcr = new MTCRHandler(createHandlerParameter); AbstractChainOfResponsibilityHandler link1 = crcr1.linkSuccessor(crcr2); AbstractChainOfResponsibilityHandler link2 = crcr2.linkSuccessor(mtcr); Assert.assertEquals("link1 should same with crcr2", link1, crcr2); Assert.assertEquals("link2 should keep crcr2 too because of mtcr is not conflict resolve handler", link2, crcr2); }