maestro.orchestra.yaml.YamlEvalScript.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maestro-orchestra Show documentation
Show all versions of maestro-orchestra Show documentation
Maestro is a server-driven platform-agnostic library that allows to drive tests for both iOS and Android using the same implementation through an intuitive API.
package maestro.orchestra.yaml
import com.fasterxml.jackson.annotation.JsonCreator
import java.lang.UnsupportedOperationException
data class YamlEvalScript(
val script: String,
val label: String? = null,
){
companion object {
@JvmStatic
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
fun parse(script: Any): YamlEvalScript {
val evalScript = when (script) {
is String -> script
is Map<*, *> -> {
val evaluatedScript = script.getOrDefault("script", "") as String
val label = script.getOrDefault("label", "") as String
return YamlEvalScript(evaluatedScript, label)
}
is Int, is Long, is Char, is Boolean, is Float, is Double -> script.toString()
else -> throw UnsupportedOperationException("Cannot deserialize evaluate script with data type ${script.javaClass}")
}
return YamlEvalScript(
script = evalScript,
)
}
}
}