AMBackwardsCompatibilityHtmlContentTransformer extends BaseRegexStringContentTransformer { @Override public String transform(String html) throws PortalException { if (html == null) { return null; } if (!html.contains("<img") || !html.contains("/documents/")) { return html; } return super.transform(html); }  @Override ContentTransformerContentType<String> getContentTransformerContentType(); @Override String transform(String html);  }
@Test public void testReplacesImageTagsWithDoubleQuotes() throws Exception { Assert.assertEquals( _CONTENT_PREFIX + "[REPLACED]" + _CONTENT_SUFFIX, _contentTransformer.transform( _CONTENT_WITH_IMAGE_AND_DOUBLE_QUOTES)); }
@Test public void testReplacesImageTagsWithSingleQuotes() throws Exception { Assert.assertEquals( _CONTENT_PREFIX + "[REPLACED]" + _CONTENT_SUFFIX, _contentTransformer.transform( _CONTENT_WITH_IMAGE_AND_SINGLE_QUOTES)); }
@Test public void testReturnsBlankForBlankContent() throws Exception { Assert.assertEquals( StringPool.BLANK, _contentTransformer.transform(StringPool.BLANK)); }
@Test public void testReturnsNullForNullContent() throws Exception { Assert.assertNull(_contentTransformer.transform(null)); }
@Test public void testReturnsTheSameHTMLIfNoImagesArePresent() throws Exception { String content = RandomTestUtil.randomString(); Assert.assertEquals(content, _contentTransformer.transform(content)); }
@Test public void testSupportsImageTagsWithNewLineCharacters() throws Exception { Assert.assertEquals( _CONTENT_PREFIX + "[REPLACED]" + _CONTENT_SUFFIX, _contentTransformer.transform(_CONTENT_WITH_IMAGE_AND_NEWLINES)); }