Move function that deals with optionals to optional utils
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / utils / OptionalsTest.kt
index 6d35509..76dd443 100644 (file)
@@ -1,7 +1,9 @@
 package net.pterodactylus.sone.utils
 
 import com.google.common.base.Optional
+import com.google.common.base.Optional.fromNullable
 import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.equalTo
 import org.hamcrest.Matchers.nullValue
 import org.junit.Test
@@ -50,4 +52,10 @@ class OptionalsTest {
                assertThat(optional.isPresent, equalTo(false))
        }
 
+       @Test
+       fun testMapPresent() {
+               val originalList = listOf(1, 2, null, 3, null)
+               assertThat(originalList.mapPresent { fromNullable(it) }, contains(1, 2, 3))
+       }
+
 }