### Question:
LinkCheckerTransformation extends AbstractTransformation implements Initializable { @Override public void transform(Block source, TransformationContext context) throws TransformationException { if (getLinkQueue().size() < MAX_LINKS_IN_QUEUE) { for (LinkBlock linkBlock : source.<LinkBlock>getBlocks( new ClassBlockMatcher(LinkBlock.class), Block.Axes.DESCENDANT)) { if (linkBlock.getReference().getType().equals(ResourceType.URL)) { String linkReference = linkBlock.getReference().getReference(); String contentReference = extractSourceContentReference(linkBlock); if (contentReference == null) { contentReference = "default"; } Map<String, Object> linkContextData = createLinkContextData(linkReference, contentReference); this.linkQueue.add(new LinkQueueItem(linkReference, contentReference, linkContextData)); } } } }  @Override void initialize(); @Override void transform(Block source, TransformationContext context); void stopLinkCheckerThread(); Queue<LinkQueueItem> getLinkQueue();  }### Answer:
@Test public void transform() throws Exception { String input = "" + "whatever" + "[[http: + "[[invalid]]" + "[[unsupportedrotocol: HTTPChecker httpChecker = this.componentManager.registerMockComponent(HTTPChecker.class); when(httpChecker.check("http: when(httpChecker.check("invalid")).thenReturn(0); LinkStateManager linkStateManager = this.componentManager.getInstance(LinkStateManager.class); transformAndWait(input, linkStateManager, 2); LinkCheckerScriptService service = this.componentManager.getInstance(ScriptService.class, "linkchecker"); Map<String, Map<String, LinkState>> states = service.getLinkStates(); LinkState state1 = states.get("http: assertEquals(200, state1.getResponseCode()); LinkState state2 = states.get("invalid").get("default"); assertEquals(0, state2.getResponseCode()); }
@Test public void transformWithSourceMetaData() throws Exception { String input = "[[http: Parser parser = this.componentManager.getInstance(Parser.class, "xwiki/2.0"); XDOM xdom = parser.parse(new StringReader(input)); MetaData metaData = new MetaData(); metaData.addMetaData(MetaData.SOURCE, "source"); XDOM newXDOM = new XDOM(xdom.getChildren(), metaData); HTTPChecker httpChecker = this.componentManager.registerMockComponent(HTTPChecker.class); when(httpChecker.check("http: Transformation transformation = this.componentManager.getInstance(Transformation.class, "linkchecker"); transformation.transform(newXDOM, new TransformationContext()); LinkStateManager linkStateManager = this.componentManager.getInstance(LinkStateManager.class); wait(linkStateManager, 1); assertNotNull(linkStateManager.getLinkStates().get("http: }