58 lines
1.9 KiB
Kotlin
58 lines
1.9 KiB
Kotlin
package de.pheerai.rcdbquery.dsl
|
|
|
|
import de.pheerai.rcdbquery.dataMappings.order.Order
|
|
import de.pheerai.rcdbquery.dataMappings.order.sortBy
|
|
import de.pheerai.rcdbquery.dataMappings.searchType.SearchType
|
|
import de.pheerai.rcdbquery.dataMappings.searchType.searchType
|
|
import de.pheerai.rcdbquery.dataMappings.type.Type
|
|
import de.pheerai.rcdbquery.dataMappings.type.type
|
|
import de.pheerai.rcdbquery.dataMappings.vendor.Vendor
|
|
import de.pheerai.rcdbquery.dataMappings.vendor.vendors
|
|
import de.pheerai.rcdbquery.dsl.params.ParamAlreadySetException
|
|
import io.kotest.assertions.asClue
|
|
import io.kotest.core.spec.style.StringSpec
|
|
import io.kotest.matchers.string.shouldContain
|
|
import io.kotest.matchers.string.shouldHaveLength
|
|
import org.junit.jupiter.api.assertThrows
|
|
|
|
class RcdbQueryDslTest : StringSpec({
|
|
"should generate a proper URL" {
|
|
rcdbQuery {
|
|
vendors {
|
|
Vendor.VEKOMA()
|
|
Vendor.MACK()
|
|
Vendor.MAURER()
|
|
}
|
|
sortBy {
|
|
Order.INVERSIONS()
|
|
Order.MANUFACTURER()
|
|
}
|
|
}.asClue {
|
|
it shouldHaveLength 61
|
|
it shouldContain "https://www.rcdb.com/r.htm?"
|
|
it shouldContain "mk="
|
|
it shouldContain "6836"
|
|
it shouldContain "6856"
|
|
it shouldContain "6905"
|
|
it shouldContain "order="
|
|
it shouldContain "24"
|
|
it shouldContain "30"
|
|
it shouldContain "ot=2"
|
|
it.filter { c -> c == '&' } shouldHaveLength 2
|
|
}
|
|
}
|
|
|
|
"Should throw if unique value is reset" {
|
|
assertThrows<ParamAlreadySetException> {
|
|
rcdbQuery {
|
|
searchType(SearchType.COASTER)
|
|
type {
|
|
Type.WOOD()
|
|
}
|
|
searchType(SearchType.AMUSEMENT_PARK)
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|