All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cucumber.scala.ScalaDefaultParameterTransformerDefinition.scala Maven / Gradle / Ivy

There is a newer version: 8.24.0
Show newest version
package io.cucumber.scala

import java.lang.reflect.Type

import io.cucumber.core.backend.{
  DefaultParameterTransformerDefinition,
  ScenarioScoped
}
import io.cucumber.cucumberexpressions.ParameterByTypeTransformer

trait ScalaDefaultParameterTransformerDefinition
    extends DefaultParameterTransformerDefinition
    with AbstractGlueDefinition {

  val details: ScalaDefaultParameterTransformerDetails

  override val location: StackTraceElement = new Exception().getStackTrace()(3)

  override val parameterByTypeTransformer: ParameterByTypeTransformer =
    (fromValue: String, toValue: Type) => {
      details.body.apply(fromValue, toValue)
    }

}

object ScalaDefaultParameterTransformerDefinition {

  def apply(
      details: ScalaDefaultParameterTransformerDetails,
      scenarioScoped: Boolean
  ): ScalaDefaultParameterTransformerDefinition = {
    if (scenarioScoped) {
      new ScalaScenarioScopedDefaultParameterTransformerDefinition(details)
    } else {
      new ScalaGlobalDefaultParameterTransformerDefinition(details)
    }
  }

}

class ScalaScenarioScopedDefaultParameterTransformerDefinition(
    override val details: ScalaDefaultParameterTransformerDetails
) extends ScalaDefaultParameterTransformerDefinition
    with ScenarioScoped {}

class ScalaGlobalDefaultParameterTransformerDefinition(
    override val details: ScalaDefaultParameterTransformerDetails
) extends ScalaDefaultParameterTransformerDefinition {}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy