Make DSL simpler.
- Still needs some fixes, e.g. how to avoid confusion (property setter/getter?)
This commit is contained in:
parent
72ea481bfd
commit
6d37da56b6
38 changed files with 202 additions and 239 deletions
|
@ -1,5 +1,15 @@
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
extra.apply {
|
||||||
|
set("kotestVersion", "4.2.0")
|
||||||
|
set("kotlinApiVersion", "1.4")
|
||||||
|
set("javaVersion", JavaVersion.VERSION_11)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> getFromExtra(prop: String) = project.extra[prop] as T
|
||||||
|
|
||||||
// TODO: Documentation
|
// TODO: Documentation
|
||||||
// TODO: Source Jar
|
// TODO: Source Jar
|
||||||
// TODO: Doc Jar
|
// TODO: Doc Jar
|
||||||
|
@ -13,29 +23,36 @@ repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "0.0.1"
|
project.version = "0.0.2"
|
||||||
project.group = "de.pheerai.rcdb"
|
project.group = "de.pheerai.rcdb"
|
||||||
|
|
||||||
|
|
||||||
java {
|
java {
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = getFromExtra("javaVersion")
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = getFromExtra("javaVersion")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib-jdk8"))
|
implementation(kotlin("stdlib-jdk8"))
|
||||||
|
|
||||||
testImplementation("io.kotest:kotest-runner-junit5-jvm:4.0.5")
|
testImplementation(
|
||||||
testImplementation("io.kotest:kotest-assertions-core-jvm:4.0.5")
|
group = "io.kotest",
|
||||||
|
name = "kotest-runner-junit5-jvm",
|
||||||
|
version = getFromExtra("kotestVersion")
|
||||||
|
)
|
||||||
|
testImplementation(
|
||||||
|
group = "io.kotest",
|
||||||
|
name = "kotest-assertions-core-jvm",
|
||||||
|
version = getFromExtra("kotestVersion")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
withType<KotlinCompile>().configureEach {
|
withType<KotlinCompile>().configureEach {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs = listOf("-XXLanguage:+InlineClasses")
|
// freeCompilerArgs = listOf("-XXLanguage:+InlineClasses")
|
||||||
apiVersion = "1.3"
|
apiVersion = getFromExtra("kotlinApiVersion")
|
||||||
languageVersion = "1.3"
|
languageVersion = getFromExtra("kotlinApiVersion")
|
||||||
jvmTarget = JavaVersion.VERSION_11.toString()
|
jvmTarget = getFromExtra<JavaVersion>("javaVersion").toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +65,7 @@ publishing {
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("maven") {
|
create<MavenPublication>("maven") {
|
||||||
groupId = project.group as String
|
groupId = project.group as String
|
||||||
artifactId = project.name as String
|
artifactId = project.name
|
||||||
version = project.version as String
|
version = project.version as String
|
||||||
|
|
||||||
from(components["java"])
|
from(components["java"])
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
2
gradlew
vendored
2
gradlew
vendored
|
@ -82,6 +82,7 @@ esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
@ -129,6 +130,7 @@ fi
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
|
1
gradlew.bat
vendored
1
gradlew.bat
vendored
|
@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.3.72"
|
kotlin("jvm") version "1.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package de.pheerai.rcdbquery
|
package de.pheerai.rcdbquery
|
||||||
|
|
||||||
|
import de.pheerai.rcdbquery.dataMappings.order.Order
|
||||||
import de.pheerai.rcdbquery.dataMappings.order.sortBy
|
import de.pheerai.rcdbquery.dataMappings.order.sortBy
|
||||||
import de.pheerai.rcdbquery.dataMappings.page.page
|
import de.pheerai.rcdbquery.dataMappings.page.page
|
||||||
import de.pheerai.rcdbquery.dataMappings.searchTerm.searchTerm
|
import de.pheerai.rcdbquery.dataMappings.searchTerm.searchTerm
|
||||||
import de.pheerai.rcdbquery.dataMappings.searchType.SearchType
|
import de.pheerai.rcdbquery.dataMappings.searchType.SearchType
|
||||||
import de.pheerai.rcdbquery.dataMappings.searchType.searchType
|
import de.pheerai.rcdbquery.dataMappings.searchType.searchType
|
||||||
import de.pheerai.rcdbquery.dataMappings.vendor.Vendor
|
import de.pheerai.rcdbquery.dataMappings.vendor.Vendor.*
|
||||||
import de.pheerai.rcdbquery.dataMappings.vendor.vendors
|
import de.pheerai.rcdbquery.dataMappings.vendor.vendors
|
||||||
import de.pheerai.rcdbquery.dsl.rcdbQuery
|
import de.pheerai.rcdbquery.dsl.rcdbQuery
|
||||||
|
|
||||||
|
@ -18,14 +19,13 @@ fun generateNameQueryUrl() = rcdbQuery {
|
||||||
searchType(SearchType.COASTER)
|
searchType(SearchType.COASTER)
|
||||||
searchTerm("Dragon")
|
searchTerm("Dragon")
|
||||||
vendors {
|
vendors {
|
||||||
vekoma()
|
VEKOMA()
|
||||||
intamin()
|
INTAMIN()
|
||||||
mack()
|
MACK()
|
||||||
of(Vendor.PRESTON_AND_BARBIERI)
|
|
||||||
}
|
}
|
||||||
sortBy {
|
sortBy {
|
||||||
manufacturer()
|
Order.MANUFACTURER()
|
||||||
inversions()
|
Order.INVERSIONS()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,6 @@ fun generatePageQueryUrl() = rcdbQuery {
|
||||||
page(3)
|
page(3)
|
||||||
searchType(SearchType.COASTER)
|
searchType(SearchType.COASTER)
|
||||||
vendors {
|
vendors {
|
||||||
intamin()
|
INTAMIN()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,30 +8,5 @@ class CategoryBuilder: MultiParamBuilder<Long, Category>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fourthDimension() = this.add(Category.FOURTH_DIMENSION)
|
override fun Category.invoke() = add(this)
|
||||||
fun brakeman() = this.add(Category.BRAKEMAN)
|
|
||||||
fun builtInhouse() = this.add(Category.BUILT_INHOUSE)
|
|
||||||
fun darkride() = this.add(Category.DARK_RIDE)
|
|
||||||
fun dualStation() = this.add(Category.DUAL_STATION)
|
|
||||||
fun enclosed() = this.add(Category.ENCLOSED)
|
|
||||||
fun floorless() = this.add(Category.FLOORLESS)
|
|
||||||
fun hybrid() = this.add(Category.HYBRID)
|
|
||||||
fun indoor() = this.add(Category.INDOOR)
|
|
||||||
fun mirror() = this.add(Category.MIRROR)
|
|
||||||
fun moebius() = this.add(Category.MOEBIUS)
|
|
||||||
fun onboardSound() = this.add(Category.ONBOARD_SOUND)
|
|
||||||
fun pendulum() = this.add(Category.PENDULUM)
|
|
||||||
fun quasiMoebius() = this.add(Category.QUASI_MOEBIUS)
|
|
||||||
fun rockingCars() = this.add(Category.ROCKING_CARS)
|
|
||||||
fun scenicRailway() = this.add(Category.SCENIC_RAILWAY)
|
|
||||||
fun shuttle() = this.add(Category.SHUTTLE)
|
|
||||||
fun sideFriction() = this.add(Category.SIDE_FRICTION)
|
|
||||||
fun singleRail() = this.add(Category.SINGLE_RAIL)
|
|
||||||
fun slidingStation() = this.add(Category.SLIDING_STATION)
|
|
||||||
fun spinningCars() = this.add(Category.SPINNING_CARS)
|
|
||||||
fun stackedStorage() = this.add(Category.STACKED_STORAGE)
|
|
||||||
fun turntableStation() = this.add(Category.TURNTABLE_STATION)
|
|
||||||
fun twin() = this.add(Category.TWIN)
|
|
||||||
fun virtualReality() = this.add(Category.VIRTUAL_REALITY)
|
|
||||||
fun waterCoaster() = this.add(Category.WATER_COASTER)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.category
|
package de.pheerai.rcdbquery.dataMappings.category
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.category(body: CategoryBuilder.() -> CategoryBuilder): ParamsCollector {
|
fun ParamsCollector.category(body: CategoryBuilder.() -> CategoryBuilder): ParamsCollector {
|
||||||
val builder = CategoryBuilder()
|
val builder = CategoryBuilder()
|
||||||
|
|
|
@ -8,7 +8,5 @@ class ClassificationBuilder : MultiParamBuilder<Long, Classification>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun rollerCoaster() = this.add(Classification.ROLLER_COASTER)
|
override fun Classification.invoke() = add(this)
|
||||||
fun poweredCoaster() = this.add(Classification.POWERED_COASTER)
|
|
||||||
fun mountainCoaster() = this.add(Classification.MOUNTAIN_COASTER)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.classification
|
package de.pheerai.rcdbquery.dataMappings.classification
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.classification(body: ClassificationBuilder.() -> ClassificationBuilder): ParamsCollector {
|
fun ParamsCollector.classification(body: ClassificationBuilder.() -> ClassificationBuilder): ParamsCollector {
|
||||||
val builder = ClassificationBuilder()
|
val builder = ClassificationBuilder()
|
||||||
|
|
|
@ -8,12 +8,5 @@ class DesignBuilder : MultiParamBuilder<Long, Design>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sitDown() = Design.SIT_DOWN
|
override fun Design.invoke() = add(this)
|
||||||
fun inverted() = Design.INVERTED
|
|
||||||
fun suspended() = Design.SUSPENDED
|
|
||||||
fun wing() = Design.WING
|
|
||||||
fun flying() = Design.FLYING
|
|
||||||
fun standUp() = Design.STAND_UP
|
|
||||||
fun bobsled() = Design.BOBSLED
|
|
||||||
fun pipeline() = Design.PIPELINE
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.design
|
package de.pheerai.rcdbquery.dataMappings.design
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.design(body: DesignBuilder.() -> DesignBuilder): ParamsCollector {
|
fun ParamsCollector.design(body: DesignBuilder.() -> DesignBuilder): ParamsCollector {
|
||||||
val builder = DesignBuilder()
|
val builder = DesignBuilder()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.internal
|
package de.pheerai.rcdbquery.dataMappings.internal
|
||||||
|
|
||||||
open class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
abstract class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
||||||
private val paramList: MutableList<T> = mutableListOf()
|
private val paramList: MutableList<T> = mutableListOf()
|
||||||
|
|
||||||
open fun add(param: T): MultiParamBuilder<U, T> {
|
open fun add(param: T): MultiParamBuilder<U, T> {
|
||||||
|
@ -19,5 +19,6 @@ open class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun build() = paramList.toList()
|
fun build() = paramList.toList()
|
||||||
}
|
|
||||||
|
|
||||||
|
abstract operator fun T.invoke(): MultiParamBuilder<U, T>
|
||||||
|
}
|
||||||
|
|
|
@ -8,32 +8,5 @@ class LayoutBuilder : MultiParamBuilder<Long, Layout>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bigApple() = this.add(Layout.BIG_APPLE)
|
override operator fun Layout.invoke() = add(this)
|
||||||
fun wackyWorm() = this.add(Layout.BIG_APPLE)
|
|
||||||
|
|
||||||
fun circleDip() = this.add(Layout.CIRCLE_DIP)
|
|
||||||
fun circularGravityRailway() = this.add(Layout.CIRCULAR_GRAVIY_RAILWAY)
|
|
||||||
fun cyclone() = this.add(Layout.CYCLONE)
|
|
||||||
fun doubleFigureEight() = this.add(Layout.DOUBLE_FIGURE_EIGHT)
|
|
||||||
fun doubleOutAndBack() = this.add(Layout.DOUBLE_OUT_AND_BACK)
|
|
||||||
fun figureEight() = this.add(Layout.FIGURE_EIGHT)
|
|
||||||
fun jungleMouse() = this.add(Layout.JUNGLE_MOUSE)
|
|
||||||
fun lShapedOutAndBack() = this.add(Layout.L_SHAPED_OUT_AND_BACK)
|
|
||||||
fun miteMouse() = this.add(Layout.MITE_MOUSE)
|
|
||||||
fun outAndBack() = this.add(Layout.OUT_AND_BACK)
|
|
||||||
fun oval() = this.add(Layout.OVAL)
|
|
||||||
fun shuttleLoop() = this.add(Layout.SHUTTLE_LOOP)
|
|
||||||
fun singleHelixCenter() = this.add(Layout.SINGLE_HELIX_CENTER)
|
|
||||||
fun singleHelixLeft() = this.add(Layout.SINGLE_HELIX_LEFT)
|
|
||||||
fun singleHelixRear() = this.add(Layout.SINGLE_HELIX_REAR)
|
|
||||||
fun singleHelixRight() = this.add(Layout.SINGLE_HELIX_RIGHT)
|
|
||||||
fun terrain() = this.add(Layout.TERRAIN)
|
|
||||||
fun triangle() = this.add(Layout.TRIANGLE)
|
|
||||||
fun tripleOutAndBack() = this.add(Layout.TRIPLE_OUT_AND_BACK)
|
|
||||||
fun twinHelix() = this.add(Layout.TWIN_HELIX)
|
|
||||||
fun twister() = this.add(Layout.TWISTER)
|
|
||||||
fun uShuttle() = this.add(Layout.U_SHUTTLE)
|
|
||||||
fun wildMouse() = this.add(Layout.WILD_MOUSE)
|
|
||||||
fun zyklon() = this.add(Layout.ZYKLON)
|
|
||||||
fun galaxy() = this.add(Layout.ZYKLON)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.layout
|
package de.pheerai.rcdbquery.dataMappings.layout
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.layout(body: LayoutBuilder.() -> LayoutBuilder): ParamsCollector {
|
fun ParamsCollector.layout(body: LayoutBuilder.() -> LayoutBuilder): ParamsCollector {
|
||||||
val builder = LayoutBuilder()
|
val builder = LayoutBuilder()
|
||||||
|
with(Layout) {
|
||||||
builder.body()
|
builder.body()
|
||||||
|
}
|
||||||
this[Layout.paramKey] = builder.build()
|
this[Layout.paramKey] = builder.build()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,30 +18,6 @@ class OrderBuilder : MultiParamBuilder<Long, Order>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun of(order: Order) = this.add(order)
|
override fun Order.invoke() = add(this)
|
||||||
fun manufacturer() = this.add(Order.MANUFACTURER)
|
|
||||||
fun inversions() = this.add(Order.INVERSIONS)
|
|
||||||
fun name() = this.add(Order.NAME)
|
|
||||||
fun location() = this.add(Order.LOCATION)
|
|
||||||
fun park() = this.add(Order.PARK)
|
|
||||||
fun opened() = this.add(Order.OPENED)
|
|
||||||
fun closed() = this.add(Order.CLOSED)
|
|
||||||
fun entered() = this.add(Order.ENTERED)
|
|
||||||
fun type() = this.add(Order.TYPE)
|
|
||||||
fun design() = this.add(Order.DESIGN)
|
|
||||||
fun classification() = this.add(Order.CLASSIFICATION)
|
|
||||||
fun layout() = this.add(Order.LAYOUT)
|
|
||||||
fun model() = this.add(Order.MODEL)
|
|
||||||
fun modelLine() = this.add(Order.MODEL_LINE)
|
|
||||||
fun speed() = this.add(Order.SPEED)
|
|
||||||
fun height() = this.add(Order.HEIGHT)
|
|
||||||
fun drop() = this.add(Order.DROP)
|
|
||||||
fun length() = this.add(Order.LENGTH)
|
|
||||||
fun angle() = this.add(Order.ANGLE)
|
|
||||||
fun serialNo() = this.add(Order.SERIAL_NO)
|
|
||||||
fun scale() = this.add(Order.SCALE)
|
|
||||||
fun rideTime() = this.add(Order.RIDE_TIME)
|
|
||||||
fun state() = this.add(Order.STATUS)
|
|
||||||
fun closing() = this.add(Order.CLOSING)
|
|
||||||
fun allRelevant() = this.addAll(Order.values().filter { it.relevantForAll })
|
fun allRelevant() = this.addAll(Order.values().filter { it.relevantForAll })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.order
|
package de.pheerai.rcdbquery.dataMappings.order
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector {
|
fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector {
|
||||||
val builder = OrderBuilder()
|
val builder = OrderBuilder()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.page
|
package de.pheerai.rcdbquery.dataMappings.page
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.page(page: Long) = also {
|
fun ParamsCollector.page(page: Long) = also {
|
||||||
this[Page.paramKey] =
|
this[Page.paramKey] =
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.searchTerm
|
package de.pheerai.rcdbquery.dataMappings.searchTerm
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.searchTerm(term: String) = also {
|
fun ParamsCollector.searchTerm(term: String) = also {
|
||||||
it[SearchTerm.paramKey] = listOf(
|
it[SearchTerm.paramKey] = listOf(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.searchType
|
package de.pheerai.rcdbquery.dataMappings.searchType
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.searchType(searchType: SearchType) = also {
|
fun ParamsCollector.searchType(searchType: SearchType) = also {
|
||||||
it[SearchType.paramKey] = searchType
|
it[SearchType.paramKey] = searchType
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.startsWith
|
package de.pheerai.rcdbquery.dataMappings.startsWith
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.startsWith(term: String) = also {
|
fun ParamsCollector.startsWith(term: String) = also {
|
||||||
this[StartsWith.paramKey] =
|
this[StartsWith.paramKey] =
|
||||||
|
|
|
@ -8,8 +8,5 @@ class StatusBuilder : MultiParamBuilder<Long, Status>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sbno() = this.add(Status.SBNO)
|
override fun Status.invoke() = add(this)
|
||||||
fun operating() = this.add(Status.OPERATING)
|
|
||||||
fun underConstruction() = this.add(Status.UNDER_CONSTRUCTION)
|
|
||||||
fun stored() = this.add(Status.STORED)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.status
|
package de.pheerai.rcdbquery.dataMappings.status
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.status(body: StatusBuilder.() -> StatusBuilder): ParamsCollector {
|
fun ParamsCollector.status(body: StatusBuilder.() -> StatusBuilder): ParamsCollector {
|
||||||
val builder = StatusBuilder()
|
val builder = StatusBuilder()
|
||||||
|
|
|
@ -8,8 +8,5 @@ class ThrillBuilder : MultiParamBuilder<Long, Thrill>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun kiddie() = this.add(Thrill.KIDDIE)
|
override fun Thrill.invoke() = add(this)
|
||||||
fun family() = this.add(Thrill.FAMILY)
|
|
||||||
fun thrill() = this.add(Thrill.THRILL)
|
|
||||||
fun extreme() = this.add(Thrill.EXTREME)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.thrill
|
package de.pheerai.rcdbquery.dataMappings.thrill
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
fun ParamsCollector.type(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
|
fun ParamsCollector.thrill(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
|
||||||
val builder = ThrillBuilder()
|
val builder = ThrillBuilder()
|
||||||
builder.body()
|
builder.body()
|
||||||
this[Thrill.paramKey] = builder.build()
|
this[Thrill.paramKey] = builder.build()
|
||||||
|
|
|
@ -8,6 +8,5 @@ class TypeBuilder : MultiParamBuilder<Long, Type>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun steel() = this.add(Type.STEEL)
|
override fun Type.invoke() = add(this)
|
||||||
fun wood() = this.add(Type.WOOD)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.type
|
package de.pheerai.rcdbquery.dataMappings.type
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dataMappings.thrill.Thrill
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
import de.pheerai.rcdbquery.dataMappings.thrill.ThrillBuilder
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
|
||||||
|
|
||||||
fun ParamsCollector.thrill(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
|
fun ParamsCollector.type(body: TypeBuilder.() -> TypeBuilder): ParamsCollector {
|
||||||
val builder = ThrillBuilder()
|
val builder = TypeBuilder()
|
||||||
builder.body()
|
builder.body()
|
||||||
this[Thrill.paramKey] = builder.build()
|
this[Type.paramKey] = builder.build()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings
|
package de.pheerai.rcdbquery.dataMappings
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dataMappings.order.Order
|
import de.pheerai.rcdbquery.dataMappings.order.Order
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
|
const val EXTRA_COLUMNS_ERROR_MESSAGE =
|
||||||
|
"The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)"
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)",
|
EXTRA_COLUMNS_ERROR_MESSAGE,
|
||||||
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||||
)
|
)
|
||||||
fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
||||||
error("The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)")
|
error(EXTRA_COLUMNS_ERROR_MESSAGE)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)",
|
EXTRA_COLUMNS_ERROR_MESSAGE,
|
||||||
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||||
)
|
)
|
||||||
fun ParamsCollector.extraColumns(vararg orders: Order): Nothing =
|
fun ParamsCollector.extraColumns(vararg orders: Order): Nothing =
|
||||||
error("The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)")
|
error(EXTRA_COLUMNS_ERROR_MESSAGE)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||||
enum class Vendor(
|
enum class Vendor(
|
||||||
override val prettyName: String,
|
override val prettyName: String,
|
||||||
override val fullName: String,
|
override val fullName: String,
|
||||||
override val paramValue: Long
|
override val paramValue: Long,
|
||||||
) : RcdbParamOption<Long>, RcdbItem {
|
) : RcdbParamOption<Long>, RcdbItem {
|
||||||
YAQIAO_MACHINE("Yaqiao", "Yaqiao Machine", 6471),
|
YAQIAO_MACHINE("Yaqiao", "Yaqiao Machine", 6471),
|
||||||
CREDIBLE("Credible", 6584),
|
CREDIBLE("Credible", 6584),
|
||||||
|
@ -118,7 +118,7 @@ enum class Vendor(
|
||||||
TAKAHASHI_KIKAI_SANGYO("Takahashi Kikai Sangyo", 7472),
|
TAKAHASHI_KIKAI_SANGYO("Takahashi Kikai Sangyo", 7472),
|
||||||
DYNAMIC("Dynamic Attractions", 7489),
|
DYNAMIC("Dynamic Attractions", 7489),
|
||||||
GOLDEN_HORSE("Golden Horse", 7492),
|
GOLDEN_HORSE("Golden Horse", 7492),
|
||||||
WIEGAND("Wiegand", "Josef Wiegand GmbH & Co. KG", 7514),
|
WIEGAND("Wiegand", 7514),
|
||||||
ASCOT("Ascot Design", 7530),
|
ASCOT("Ascot Design", 7530),
|
||||||
DAL_AMUSEMENT_RIDES("DAL Amusement Rides Company", 7536),
|
DAL_AMUSEMENT_RIDES("DAL Amusement Rides Company", 7536),
|
||||||
CHILDRESS_COASTER("Childress Coaster", 7550),
|
CHILDRESS_COASTER("Childress Coaster", 7550),
|
||||||
|
@ -255,8 +255,11 @@ enum class Vendor(
|
||||||
|
|
||||||
fun searchByName(name: String): List<Vendor> {
|
fun searchByName(name: String): List<Vendor> {
|
||||||
val searchName = name.toLowerCase()
|
val searchName = name.toLowerCase()
|
||||||
return values().filter {
|
return values()
|
||||||
it.fullName.toLowerCase().contains(searchName)
|
.filter {
|
||||||
|
it.fullName
|
||||||
|
.toLowerCase()
|
||||||
|
.contains(searchName)
|
||||||
}.toList()
|
}.toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,5 @@ class VendorBuilder : MultiParamBuilder<Long, Vendor>() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun of(vendor: Vendor) = this.add(vendor)
|
override fun Vendor.invoke() = add(this)
|
||||||
fun vekoma() = this.add(Vendor.VEKOMA)
|
|
||||||
fun intamin() = this.add(Vendor.INTAMIN)
|
|
||||||
fun mack() = this.add(Vendor.MACK)
|
|
||||||
fun bandm() = this.add(Vendor.B_AND_M)
|
|
||||||
fun gerstlauer() = this.add(Vendor.GERSTLAUER)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.pheerai.rcdbquery.dataMappings.vendor
|
package de.pheerai.rcdbquery.dataMappings.vendor
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dsl.ParamsCollector
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
|
||||||
// TODO: Try to generify. This is currently lacking some sort of "This interface requires a companion implementing that interface"
|
// TODO: Try to generify. This is currently lacking some sort of "This interface requires a companion implementing that interface"
|
||||||
fun ParamsCollector.vendors(body: VendorBuilder.() -> VendorBuilder): ParamsCollector {
|
fun ParamsCollector.vendors(body: VendorBuilder.() -> VendorBuilder): ParamsCollector {
|
||||||
|
|
48
src/main/kotlin/de/pheerai/rcdbquery/dsl/params/Collector.kt
Normal file
48
src/main/kotlin/de/pheerai/rcdbquery/dsl/params/Collector.kt
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package de.pheerai.rcdbquery.dsl.params
|
||||||
|
|
||||||
|
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||||
|
import de.pheerai.rcdbquery.dataMappings.searchType.SearchType
|
||||||
|
import de.pheerai.rcdbquery.dsl.RcdbParams
|
||||||
|
|
||||||
|
class ParamsCollector {
|
||||||
|
private val multiParams: MutableMap<String, List<RcdbParamOption<Any>>> = mutableMapOf()
|
||||||
|
private val singleParams: MutableMap<String, RcdbParamOption<Any>> = mutableMapOf()
|
||||||
|
|
||||||
|
fun build() = RcdbParams(buildMulti(), buildSingle())
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the Query Params from this builder.
|
||||||
|
* If no Search type has been set, this will default to "Coaster"
|
||||||
|
*/
|
||||||
|
private fun buildMulti() = multiParams.apply {
|
||||||
|
// Defaults go here, if any
|
||||||
|
}
|
||||||
|
.filter { it.value.isNotEmpty() }
|
||||||
|
.mapValues { e -> e.value.map { o -> o.paramValue.toString() } }
|
||||||
|
.let { MultiParams(it) }
|
||||||
|
|
||||||
|
private fun buildSingle() = singleParams.apply {
|
||||||
|
putIfAbsent(SearchType.paramKey, SearchType.COASTER)
|
||||||
|
}
|
||||||
|
.mapValues { e -> e.value.paramValue.toString() }
|
||||||
|
.let { SingleParams(it) }
|
||||||
|
|
||||||
|
operator fun set(paramName: String, options: List<RcdbParamOption<Any>>) {
|
||||||
|
this.multiParams[paramName] = options
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun set(paramName: String, option: RcdbParamOption<Any>) {
|
||||||
|
if (paramName !in singleParams && paramName !in multiParams) {
|
||||||
|
this.singleParams[paramName] = option
|
||||||
|
} else {
|
||||||
|
throw ParamAlreadySetException("Parameter $paramName already set.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSingle(paramName: String) = this.multiParams[paramName] ?: this.singleParams[paramName]
|
||||||
|
fun getMulti(paramName: String) = this.multiParams[paramName]
|
||||||
|
|
||||||
|
fun keys() = this.multiKeys().plus(singleKeys())
|
||||||
|
private fun multiKeys() = this.multiParams.keys.toSet()
|
||||||
|
private fun singleKeys() = this.singleParams.keys.toSet()
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package de.pheerai.rcdbquery.dsl.params
|
||||||
|
|
||||||
|
sealed class BaseParams<T> {
|
||||||
|
abstract val params: Map<String, T>
|
||||||
|
}
|
||||||
|
|
||||||
|
class MultiParams(override val params: Map<String, List<String>>) : BaseParams<List<String>>()
|
||||||
|
class SingleParams(override val params: Map<String, String>) : BaseParams<String>()
|
|
@ -0,0 +1,3 @@
|
||||||
|
package de.pheerai.rcdbquery.dsl.params
|
||||||
|
|
||||||
|
class ParamAlreadySetException(message: String) : IllegalArgumentException(message)
|
|
@ -1,19 +1,19 @@
|
||||||
package de.pheerai.rcdbquery.dsl
|
package de.pheerai.rcdbquery.dsl
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
import de.pheerai.rcdbquery.dsl.params.MultiParams
|
||||||
import de.pheerai.rcdbquery.dataMappings.searchType.SearchType
|
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||||
|
import de.pheerai.rcdbquery.dsl.params.SingleParams
|
||||||
// TODO: Restructure
|
|
||||||
|
|
||||||
data class RcdbParams(
|
data class RcdbParams(
|
||||||
val multiParams: MultiParams,
|
val multiParams: MultiParams,
|
||||||
val singleParams: SingleParams
|
val singleParams: SingleParams,
|
||||||
) {
|
) {
|
||||||
fun toStrings(): List<String> {
|
fun toStrings(): List<String> {
|
||||||
val multiParamSequence: Sequence<Pair<String, String>> = this.multiParams
|
val multiParamSequence: Sequence<Pair<String, String>> = this.multiParams
|
||||||
.params
|
.params
|
||||||
|
.mapValues { it.value.joinToString(separator = ",") }
|
||||||
|
.map { it.toPair() }
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { e -> e.key to e.value.joinToString(separator = ",") }
|
|
||||||
val singleParamSequence: Sequence<Pair<String, String>> = this.singleParams
|
val singleParamSequence: Sequence<Pair<String, String>> = this.singleParams
|
||||||
.params
|
.params
|
||||||
.asSequence()
|
.asSequence()
|
||||||
|
@ -24,58 +24,6 @@ data class RcdbParams(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class Params<T> {
|
|
||||||
abstract val params: Map<String, T>
|
|
||||||
}
|
|
||||||
|
|
||||||
class ParamAlreadySetException(message: String) : IllegalArgumentException(message)
|
|
||||||
|
|
||||||
class MultiParams(override val params: Map<String, List<String>>) : Params<List<String>>()
|
|
||||||
class SingleParams(override val params: Map<String, String>) : Params<String>()
|
|
||||||
|
|
||||||
class ParamsCollector {
|
|
||||||
private val multiParams: MutableMap<String, List<RcdbParamOption<Any>>> = mutableMapOf()
|
|
||||||
private val singleParams: MutableMap<String, RcdbParamOption<Any>> = mutableMapOf()
|
|
||||||
|
|
||||||
fun build() = RcdbParams(buildMulti(), buildSingle())
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the Query Params from this builder.
|
|
||||||
* If no Search type has been set, this will default to "Coaster"
|
|
||||||
*/
|
|
||||||
private fun buildMulti() = multiParams.apply {
|
|
||||||
// Defaults go here, if any
|
|
||||||
}
|
|
||||||
.filter { it.value.isNotEmpty() }
|
|
||||||
.mapValues { e -> e.value.map { o -> o.paramValue.toString() } }
|
|
||||||
.let { MultiParams(it) }
|
|
||||||
|
|
||||||
private fun buildSingle() = singleParams.apply {
|
|
||||||
putIfAbsent(SearchType.paramKey, SearchType.COASTER)
|
|
||||||
}
|
|
||||||
.mapValues { e -> e.value.paramValue.toString() }
|
|
||||||
.let { SingleParams(it) }
|
|
||||||
|
|
||||||
operator fun set(paramName: String, options: List<RcdbParamOption<Any>>) {
|
|
||||||
this.multiParams[paramName] = options
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun set(paramName: String, option: RcdbParamOption<Any>) {
|
|
||||||
if (paramName !in singleParams && paramName !in multiParams) {
|
|
||||||
this.singleParams[paramName] = option
|
|
||||||
} else {
|
|
||||||
throw ParamAlreadySetException("Parameter $paramName already set.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getSingle(paramName: String) = this.multiParams[paramName] ?: this.singleParams[paramName]
|
|
||||||
fun getMulti(paramName: String) = this.multiParams[paramName]
|
|
||||||
|
|
||||||
fun keys() = this.multiKeys().plus(singleKeys())
|
|
||||||
private fun multiKeys() = this.multiParams.keys.toSet()
|
|
||||||
private fun singleKeys() = this.singleParams.keys.toSet()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun rcdbQuery(body: ParamsCollector.() -> ParamsCollector) =
|
fun rcdbQuery(body: ParamsCollector.() -> ParamsCollector) =
|
||||||
RcdbUrlQuery("https://www.rcdb.com/r.htm?", rcdbQueryParams(body)).toString()
|
RcdbUrlQuery("https://www.rcdb.com/r.htm?", rcdbQueryParams(body)).toString()
|
||||||
|
|
||||||
|
|
7
src/test/kotlin/de/pheerai/rcdbquery/TestConfig.kt
Normal file
7
src/test/kotlin/de/pheerai/rcdbquery/TestConfig.kt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package de.pheerai.rcdbquery
|
||||||
|
|
||||||
|
import io.kotest.core.config.AbstractProjectConfig
|
||||||
|
|
||||||
|
class TestConfig : AbstractProjectConfig() {
|
||||||
|
override val globalAssertSoftly = true
|
||||||
|
}
|
|
@ -1,38 +1,57 @@
|
||||||
package de.pheerai.rcdbquery.dsl
|
package de.pheerai.rcdbquery.dsl
|
||||||
|
|
||||||
import de.pheerai.rcdbquery.dataMappings.vendor.Vendor
|
import de.pheerai.rcdbquery.dataMappings.order.Order
|
||||||
import de.pheerai.rcdbquery.dataMappings.order.sortBy
|
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.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.core.spec.style.StringSpec
|
||||||
import io.kotest.matchers.shouldBe
|
|
||||||
import io.kotest.matchers.string.shouldContain
|
import io.kotest.matchers.string.shouldContain
|
||||||
|
import io.kotest.matchers.string.shouldHaveLength
|
||||||
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
|
||||||
class RcdbQueryDslTest : StringSpec({
|
class RcdbQueryDslTest : StringSpec({
|
||||||
|
|
||||||
"should generate a proper URL" {
|
"should generate a proper URL" {
|
||||||
val actual = rcdbQuery {
|
rcdbQuery {
|
||||||
vendors {
|
vendors {
|
||||||
vekoma()
|
Vendor.VEKOMA()
|
||||||
mack()
|
Vendor.MACK()
|
||||||
of(Vendor.MAURER)
|
Vendor.MAURER()
|
||||||
}
|
}
|
||||||
sortBy {
|
sortBy {
|
||||||
inversions()
|
Order.INVERSIONS()
|
||||||
manufacturer()
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.length shouldBe 61
|
"Should throw if unique value is reset" {
|
||||||
actual.shouldContain("https://www.rcdb.com/r.htm?")
|
assertThrows<ParamAlreadySetException> {
|
||||||
actual.shouldContain("mk=")
|
rcdbQuery {
|
||||||
actual.shouldContain("6836")
|
searchType(SearchType.COASTER)
|
||||||
actual.shouldContain("6856")
|
type {
|
||||||
actual.shouldContain("6905")
|
Type.WOOD()
|
||||||
actual.shouldContain("order=")
|
}
|
||||||
actual.shouldContain("24")
|
searchType(SearchType.AMUSEMENT_PARK)
|
||||||
actual.shouldContain("30")
|
}
|
||||||
actual.shouldContain("ot=2")
|
}
|
||||||
actual.filter { it == '&' }.length shouldBe 2
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue