From: David ‘Bombe’ Roden Date: Sun, 2 Nov 2014 11:09:17 +0000 (+0100) Subject: Add unit test for CSS class name filter. X-Git-Tag: 0.9-rc1^2~3^2~58 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fbc1a448540fd1fd484a7e4e76a2132c2976e90d;p=Sone.git Add unit test for CSS class name filter. --- diff --git a/src/test/java/net/pterodactylus/sone/template/CssClassNameFilterTest.java b/src/test/java/net/pterodactylus/sone/template/CssClassNameFilterTest.java new file mode 100644 index 0000000..7b47567 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/template/CssClassNameFilterTest.java @@ -0,0 +1,35 @@ +package net.pterodactylus.sone.template; + +import static java.util.Collections.emptyMap; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Map; + +import org.hamcrest.Matchers; +import org.junit.Test; + +/** + * Unit test for {@link CssClassNameFilter}. + * + * @author David ‘Bombe’ Roden + */ +public class CssClassNameFilterTest { + + private static final Map EMPTY_MAP = emptyMap(); + private final CssClassNameFilter filter = new CssClassNameFilter(); + + @Test + public void stringsAreFiltered() { + String allCharacters = "name with äöü"; + String filteredCharacters = "name_with____"; + assertThat(filter.format(null, allCharacters, EMPTY_MAP), + Matchers.is(filteredCharacters)); + } + + @Test + public void nullIsFiltered() { + assertThat(filter.format(null, null, EMPTY_MAP), + Matchers.is("null")); + } + +}