ModuleTextFormatter implements ITextFormatter { @Override public String format(String text) { for (ITextFormatter formatter : formatters) { text = formatter.format(text); } if (visibleVerseNumbers) { text = text.replaceAll(VERSE_NUMBER_PATTERN, "$1<b>$2</b>$3 ").replaceAll("null", ""); } else { text = text.replaceAll(VERSE_NUMBER_PATTERN, ""); } return text; } ModuleTextFormatter(BaseModule module, PreferenceHelper prefHelper);  ModuleTextFormatter(BaseModule module, ITextFormatter formatter); void setVisibleVerseNumbers(boolean visible); @Override String format(String text);  }
@Test public void testFormatCleanTags() throws Exception { ModuleTextFormatter formatter = new ModuleTextFormatter(mModule, prefHelper); String result = formatter.format(testVerses); Assert.assertTrue(result.contains("<I>")); Assert.assertTrue(result.contains("<p>")); }
@Test public void testFormatModuleWithStrong() throws Exception { mModule.setContainsStrong(true); ModuleTextFormatter formatter = new ModuleTextFormatter(mModule, prefHelper); String result = formatter.format(testVersesWithStrong); Assert.assertFalse(result.contains("G1234")); Assert.assertFalse(result.contains("G59")); Assert.assertFalse(result.contains("1234")); Assert.assertFalse(result.contains("59")); Pattern pattern = Pattern.compile("\\s{2,}"); Matcher matcher = pattern.matcher(result); Assert.assertFalse(matcher.find()); }
@Test public void testFormatModuleWithoutStrong() throws Exception { mModule.setContainsStrong(false); ModuleTextFormatter formatter = new ModuleTextFormatter(mModule, prefHelper); String result = formatter.format(testVersesWithStrong); Assert.assertTrue(result.contains("G1234")); Assert.assertTrue(result.contains("G59")); Assert.assertTrue(result.contains("1234")); Assert.assertTrue(result.contains("59")); }