cleanFragments.add(HerdStringUtils.stripHtml(fragment, preTag, postTag));
@Test public void testDecodeBase64() { // Test decode using hard coded values. assertEquals("UT_SomeText", HerdStringUtils.decodeBase64("VVRfU29tZVRleHQ=")); // Test decode using random string and encoder. String encodedText = StringUtils.toEncodedString(Base64.getEncoder().encode(STRING_VALUE.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); assertEquals(STRING_VALUE, HerdStringUtils.decodeBase64(encodedText)); }
@Test public void testGetShortDescription() { String longString = RandomStringUtils.randomAlphabetic(500); String result = HerdStringUtils.getShortDescription(longString, 10); assertEquals(result.length(), 10); }
.setShortDescription(HerdStringUtils.getShortDescription((String) sourceMap.get(DESCRIPTION_SOURCE), tagShortDescMaxLength)); HerdStringUtils.getShortDescription((String) sourceMap.get(DESCRIPTION_SOURCE), businessObjectDefinitionShortDescMaxLength));
.setShortDescription(HerdStringUtils.getShortDescription((String) sourceMap.get(DESCRIPTION_SOURCE), tagShortDescMaxLength)); HerdStringUtils.getShortDescription((String) sourceMap.get(DESCRIPTION_SOURCE), businessObjectDefinitionShortDescMaxLength));
cleanFragments.add(HerdStringUtils.stripHtml(fragment, preTag, postTag));
definition.setShortDescription(HerdStringUtils.getShortDescription(businessObjectDefinitionEntity.getDescription(), shortDescMaxLength));
@Test public void testStripHtmlDirtyFragment() { String result = HerdStringUtils.stripHtml("<li>fragment with <b>html</b></li>"); assertEquals("fragment with html", result); }
definition.setShortDescription(HerdStringUtils.getShortDescription(businessObjectDefinitionEntity.getDescription(), shortDescMaxLength));
@Test public void testStripHtmlCleanFragment() { String result = HerdStringUtils.stripHtml("fragment\nwith no html"); assertEquals("fragment\nwith no html", result); }
@Test public void testStripHtmlDirtyFragmentWithWhitelist() { String result = HerdStringUtils.stripHtml("fragment<li><b> with <hlt>no</hlt></b> html</li>", "<hlt>"); assertEquals("fragment with <hlt>no</hlt> html", result); }
@Test public void testStripHtmlDirtyFragmentWithWhitelistWithStyle() { String result = HerdStringUtils.stripHtml("fragment<li><b> with <hlt class=\"highlight\">no</hlt></b> html</li>", "<hlt>"); assertEquals("fragment with <hlt class=\"highlight\">no</hlt> html", result); }
@Test public void testStripHtmlDirtyFragmentWithPartialTags() { String result = HerdStringUtils.stripHtml("fragment<li><b> with no</b> html<l"); assertEquals("fragment with no html", result); }
@Test public void testStripHtmlDirtyFragmentWithMultipleWhitelistTags() { String result = HerdStringUtils.stripHtml("fragment<li><b> with <hlt>no</hlt></b> html</li>", "<hlt>", "<b>"); assertEquals("fragment<b> with <hlt>no</hlt></b> html", result); } }