package net.pokeranalytics.android.filter

import androidx.test.ext.junit.runners.AndroidJUnit4
import net.pokeranalytics.android.exceptions.FilterValueMapException
import net.pokeranalytics.android.model.filter.DateFilterable
import net.pokeranalytics.android.model.filter.FilterManager
import net.pokeranalytics.android.model.filter.SessionFilterable
import net.pokeranalytics.android.model.realm.Session
import org.junit.Test
import org.junit.runner.RunWith
import java.util.*

@RunWith(AndroidJUnit4::class)
class ExceptionFilterInstrumentedTest: BaseFilterInstrumentedUnitTest() {

    @Test(expected = FilterValueMapException::class)
    fun testFilterException() {
        val realm = this.mockRealm
         FilterManager().filter(
            realm,
            Session::class.java,
            arrayListOf(SessionFilterable.BLINDS)
        )
    }

    @Test(expected = FilterValueMapException::class)
    fun testValueKeyFilterException() {
        val filter = DateFilterable.STARTED_FROM_DATE
        filter.valueMap = mapOf("bob" to Date())

        val realm = this.mockRealm
        FilterManager().filter(
            realm,
            Session::class.java,
            arrayListOf(filter)
        )
    }

    @Test(expected = FilterValueMapException::class)
    fun testSubValueKeyFilterException() {
        val filter = SessionFilterable.BLINDS
        filter.valueMap = mapOf("map" to arrayOf(mapOf(
            "bob" to 0.5,
            "bb" to 1.0,
            "code" to null
        )))

        val realm = this.mockRealm
        FilterManager().filter(
            realm,
            Session::class.java,
            arrayListOf(filter)
        )
    }
}