Add unit test for CSS class name filter.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 2 Nov 2014 11:09:17 +0000 (12:09 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 2 Nov 2014 11:09:17 +0000 (12:09 +0100)
src/test/java/net/pterodactylus/sone/template/CssClassNameFilterTest.java [new file with mode: 0644]

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 (file)
index 0000000..7b47567
--- /dev/null
@@ -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 <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class CssClassNameFilterTest {
+
+       private static final Map<String, Object> 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.<Object>is(filteredCharacters));
+       }
+
+       @Test
+       public void nullIsFiltered() {
+               assertThat(filter.format(null, null, EMPTY_MAP),
+                               Matchers.<Object>is("null"));
+       }
+
+}