main.kotlin.ch.tutteli.atrium.logic.creating.impl.rootExpectBuilderImpl.kt Maven / Gradle / Ivy
package ch.tutteli.atrium.logic.creating.impl
import ch.tutteli.atrium.core.ExperimentalNewExpectTypes
import ch.tutteli.atrium.core.Some
import ch.tutteli.atrium.creating.RootExpect
import ch.tutteli.atrium.creating.RootExpectOptions
import ch.tutteli.atrium.logic.creating.RootExpectBuilder
import ch.tutteli.atrium.reporting.translating.Translatable
class ExpectationVerbStepImpl(override val subject: T) : RootExpectBuilder.ExpectationVerbStep {
override fun withVerb(verb: Translatable): RootExpectBuilder.OptionsStep =
RootExpectBuilder.OptionsStep(subject, verb)
}
class OptionsStepImpl(
override val subject: T,
override val expectationVerb: Translatable
) : RootExpectBuilder.OptionsStep {
@ExperimentalNewExpectTypes
override fun withOptions(rootExpectOptions: RootExpectOptions): RootExpectBuilder.FinalStep =
toFinalStep(rootExpectOptions)
@ExperimentalNewExpectTypes
override fun withoutOptions(): RootExpectBuilder.FinalStep = toFinalStep(null)
@ExperimentalNewExpectTypes
private fun toFinalStep(rootExpectOptions: RootExpectOptions?) =
RootExpectBuilder.FinalStep(subject, expectationVerb, rootExpectOptions)
}
@ExperimentalNewExpectTypes
class FinalStepImpl(
override val subject: T,
override val expectationVerb: Translatable,
override val options: RootExpectOptions?
) : RootExpectBuilder.FinalStep {
override fun build(): RootExpect = RootExpect(Some(subject), expectationVerb, options)
}