@@ -0,0 +1,2519 @@
+// Copyright (C) 2016 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.googlesource.gerrit.plugins.xdocs.formatter;%0A%0Aimport static org.easymock.EasyMock.*;%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport com.googlesource.gerrit.plugins.xdocs.ConfigSection;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0Aimport org.apache.commons.lang.StringUtils;%0Aimport org.easymock.IAnswer;%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.TemporaryFolder;%0A%0Apublic class AsciidoctorFormatterTest %7B%0A%0A  private ConfigSection cfg;%0A  private AsciidoctorFormatter formatter;%0A%0A  @Rule%0A  public TemporaryFolder tmp = new TemporaryFolder();%0A%0A  @Before%0A  public void setUp() throws IOException %7B%0A    FormatterUtil util = createNiceMock(FormatterUtil.class);%0A%0A    // To simplify things, make applyCss() a no-op and return the HTML code as-is.%0A    expect(util.applyCss(anyString(), anyString(), anyString())).andAnswer(%0A      new IAnswer%3CString%3E() %7B%0A        @Override%0A        public String answer() throws Throwable %7B%0A          // The first argument is the HTML code.%0A          return (String) getCurrentArguments()%5B0%5D;%0A        %7D%0A      %7D%0A    );%0A%0A    replay(util);%0A%0A    cfg = createNiceMock(ConfigSection.class);%0A%0A    // Do not expect any behavior from the ConfigSection itself.%0A    replay(cfg);%0A%0A    Formatters formatters = createNiceMock(Formatters.class);%0A%0A    // Avoid a NPE by just returning the ConfigSection mock object.%0A    expect(formatters.getFormatterConfig(anyString(), anyString())).andReturn(cfg);%0A%0A    replay(formatters);%0A%0A    formatter = new AsciidoctorFormatter(tmp.newFolder(), util, formatters);%0A  %7D%0A%0A  @Test%0A  public void basicTextFormattingWorks() throws IOException %7B%0A    String raw = %22_italic_ *bold* %60monospace%60%22;%0A    String formatted = %22%3Cem%3Eitalic%3C/em%3E %3Cstrong%3Ebold%3C/strong%3E %3Ccode%3Emonospace%3C/code%3E%22;%0A    assertEquals(StringUtils.countMatches(formatter.format(null, null, null, null, cfg, raw), formatted), 1);%0A  %7D%0A%7D%0A

Add a unit test for the AsciidoctorFormatter