Add unit test for unique element filter
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 20 Nov 2016 12:27:40 +0000 (13:27 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 20 Nov 2016 13:47:32 +0000 (14:47 +0100)
src/test/kotlin/net/pterodactylus/sone/template/UniqueElementFilterTest.kt [new file with mode: 0644]

diff --git a/src/test/kotlin/net/pterodactylus/sone/template/UniqueElementFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/UniqueElementFilterTest.kt
new file mode 100644 (file)
index 0000000..a7b21c1
--- /dev/null
@@ -0,0 +1,27 @@
+package net.pterodactylus.sone.template
+
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.equalTo
+import org.junit.Test
+
+/**
+ * Unit test for [UniqueElementFilter].
+ */
+class UniqueElementFilterTest {
+
+       private val filter = UniqueElementFilter()
+
+       @Test
+       fun `filter returns object if object is not a collection`() {
+               val someObject = Any()
+               assertThat(filter.format(null, someObject, null), equalTo<Any>(someObject))
+       }
+
+       @Test
+       fun `filter returns a set containing all unique elements of a given collection`() {
+               val objects = listOf(Any(), Any(), Any())
+               val collection = listOf(objects[0], objects[1], objects[2], objects[0], objects[1])
+               assertThat(filter.format(null, collection, null), equalTo<Any>(objects.toSet()))
+       }
+
+}