/* * Copyright 2011 gitblit.com. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.gitblit.tests; import java.util.HashMap; import java.util.Map; import org.junit.Test; import com.gitblit.IStoredSettings; import com.gitblit.Keys; import com.gitblit.tests.mock.MemorySettings; import com.gitblit.utils.MarkdownUtils; public class MarkdownUtilsTest extends GitblitUnitTest { @Test public void testMarkdown() throws Exception { assertEquals("
THIS is a test
", MarkdownUtils.transformMarkdown("**THIS** is a test")); assertEquals("** THIS ** is a test
", MarkdownUtils.transformMarkdown("** THIS ** is a test")); assertEquals("**THIS ** is a test
", MarkdownUtils.transformMarkdown("**THIS ** is a test")); assertEquals("** THIS** is a test
", MarkdownUtils.transformMarkdown("** THIS** is a test")); assertEquals("test |
test |
<test> |
<test> |
" + String.format(mentionHtml, "j.doe") + "
"; assertEquals(output, MarkdownUtils.transformGFM(settings, input, repositoryName)); input = " @j.doe"; output = "" + String.format(mentionHtml, "j.doe") + "
"; assertEquals(output, MarkdownUtils.transformGFM(settings, input, repositoryName)); input = "@j.doe."; output = "" + String.format(mentionHtml, "j.doe") + ".
"; assertEquals(output, MarkdownUtils.transformGFM(settings, input, repositoryName)); input = "To @j.doe: ask @jim.beam!"; output = "To " + String.format(mentionHtml, "j.doe") + ": ask " + String.format(mentionHtml, "jim.beam") + "!
"; assertEquals(output, MarkdownUtils.transformGFM(settings, input, repositoryName)); input = "@sta.rt\n" + "\n" + "User mentions in tickets are broken.\n" + "So:\n" + "@mc_guyver can fix this.\n" + "@j.doe, can you test after the fix by @m+guyver?\n" + "Please review this, @jim.beam!\n" + "Was reported by @jill and @j!doe from jane@doe yesterday.\n" + "\n" + "@jack.daniels can vote for john@wayne.name hopefully.\n" + "@en.de"; output = "" + String.format(mentionHtml, "sta.rt") + "
" + "" + "User mentions in tickets are broken.
"
+ "So:
"
+ String.format(mentionHtml, "mc_guyver") + " can fix this.
"
+ String.format(mentionHtml, "j.doe") + ", can you test after the fix by " + String.format(mentionHtml, "m+guyver") + "?
"
+ "Please review this, " + String.format(mentionHtml, "jim.beam") + "!
"
+ "Was reported by " + String.format(mentionHtml, "jill")
+ " and " + String.format(mentionHtml, "j!doe")
+ " from jane@doe yesterday."
+ "
" + String.format(mentionHtml, "jack.daniels") + " can vote for "
+ "john@wayne.name hopefully.
"
+ String.format(mentionHtml, "en.de")
+ "