All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmTest.io.mths.swing.flow.optional.TakeIfPresentTest.kt Maven / Gradle / Ivy

The newest version!
package io.mths.swing.flow.optional

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.test.runTest
import org.amshove.kluent.`should be equal to`
import java.util.Optional
import kotlin.test.Test

@OptIn(ExperimentalCoroutinesApi::class)
class TakeIfPresentTest {
    @Test
    fun `Drop empty optionals`() = runTest {
        val optionals = flowOf(
            Optional.empty(),
            Optional.of("Single"),
            Optional.empty()
        )
        val presentValueCount =
            optionals.takeIfPresent()
                .toList()
                .size

        presentValueCount `should be equal to` 1
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy