### Question:
UriLinkifier { public static void linkifyText(String text, StringBuffer outputBuffer) { int currentPos = 0; Matcher matcher = URI_SCHEME.matcher(text); while (matcher.find(currentPos)) { int startPos = matcher.start(1); String textBeforeMatch = text.substring(currentPos, startPos); outputBuffer.append(textBeforeMatch); String scheme = matcher.group(1).toLowerCase(Locale.US); UriParser parser = SUPPORTED_URIS.get(scheme); int newPos = parser.linkifyUri(text, startPos, outputBuffer); boolean uriWasNotLinkified = newPos <= startPos; if (uriWasNotLinkified) { outputBuffer.append(text.charAt(startPos)); currentPos = startPos + 1; } else { currentPos = (newPos > currentPos) ? newPos : currentPos + 1; } if (currentPos >= text.length()) { break; } } String textAfterLastMatch = text.substring(currentPos); outputBuffer.append(textAfterLastMatch); }  static void linkifyText(String text, StringBuffer outputBuffer);  }### Answer:
@Test public void emptyText() { String text = ""; UriLinkifier.linkifyText(text, outputBuffer); assertEquals(text, outputBuffer.toString()); }
@Test public void textWithoutUri_shouldBeCopiedToOutputBuffer() { String text = "some text here"; UriLinkifier.linkifyText(text, outputBuffer); assertEquals(text, outputBuffer.toString()); }
@Test public void simpleUri() { String uri = "http: UriLinkifier.linkifyText(uri, outputBuffer); assertLinkOnly(uri, outputBuffer); }
@Test public void uriPrecededBySpace() { String text = " http: UriLinkifier.linkifyText(text, outputBuffer); assertEquals(" <a href=\"http: }
@Test public void uriPrecededByOpeningParenthesis() { String text = "(http: UriLinkifier.linkifyText(text, outputBuffer); assertEquals("(<a href=\"http: }
@Test public void uriPrecededBySomeText() { String uri = "Check out my fantastic URI: http: UriLinkifier.linkifyText(uri, outputBuffer); assertEquals("Check out my fantastic URI: <a href=\"http: outputBuffer.toString()); }
@Test public void uriWithTrailingText() { String uri = "http: UriLinkifier.linkifyText(uri, outputBuffer); assertEquals("<a href=\"http: }
@Test public void uriEmbeddedInText() { String uri = "prefix http: UriLinkifier.linkifyText(uri, outputBuffer); assertEquals("prefix <a href=\"http: }
@Test public void uriWithUppercaseScheme() { String uri = "HTTP: UriLinkifier.linkifyText(uri, outputBuffer); assertEquals("<a href=\"HTTP: }
@Test public void uriNotPrecededByValidSeparator_shouldNotBeLinkified() { String text = "myhttp: UriLinkifier.linkifyText(text, outputBuffer); assertEquals(text, outputBuffer.toString()); }
@Test public void uriNotPrecededByValidSeparatorFollowedByValidUri() { String text = "myhttp: http: UriLinkifier.linkifyText(text, outputBuffer); assertEquals("myhttp: <a href=\"http: }
@Test public void schemaMatchWithInvalidUriInMiddleOfTextFollowedByValidUri() { String text = "prefix http:42 http: UriLinkifier.linkifyText(text, outputBuffer); assertEquals("prefix http:42 <a href=\"http: }
@Test public void multipleValidUrisInRow() { String text = "prefix http: UriLinkifier.linkifyText(text, outputBuffer); assertEquals( "prefix <a href=\"http: "<a href=\"http: outputBuffer.toString()); }