From fbc1a448540fd1fd484a7e4e76a2132c2976e90d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 2 Nov 2014 12:09:17 +0100 Subject: [PATCH] Add unit test for CSS class name filter. --- .../sone/template/CssClassNameFilterTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/template/CssClassNameFilterTest.java 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")); + } + +} -- 2.7.4