com.personio.synthetics.step.StepUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datadog-synthetic-test-support Show documentation
Show all versions of datadog-synthetic-test-support Show documentation
Kotlin library for managing Datadog Synthetic test as code
package com.personio.synthetics.step
import com.datadog.api.client.v1.model.SyntheticsStep
import com.personio.synthetics.client.BrowserTest
internal inline fun SyntheticsStep.withParamType(f: T.() -> T): T =
(params as? T ?: throw IllegalArgumentException("Expected ${T::class} but found ${params!!::class}.")).f()
internal inline fun BrowserTest.addStep(
stepName: String,
step: T,
f: T.() -> Unit,
): T {
check(stepName.isNotBlank()) { "The step name must not be empty." }
with(
step as? SyntheticsStep ?: throw IllegalArgumentException(
"Expected object of ${SyntheticsStep::class} or it's child but got ${T::class}.",
),
) {
name = stepName
addStepsItem(this)
}
return step.apply { f() }
}
internal inline fun BrowserTest.addStep(
stepName: String,
f: SyntheticsStep.() -> Unit,
): SyntheticsStep {
check(stepName.isNotBlank()) { "The step name must not be empty." }
return SyntheticsStep().apply {
name = stepName
f()
addStepsItem(this)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy