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

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

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

import java.util.{List => JavaList}

import io.cucumber.core.backend.ScenarioScoped
import io.cucumber.datatable.{DataTableType, TableRowTransformer}

import scala.jdk.CollectionConverters._

trait ScalaDataTableOptionalRowDefinition[T]
    extends ScalaDataTableTypeDefinition {

  val details: ScalaDataTableOptionalRowTypeDetails[T]

  override val emptyPatterns: Seq[String] = details.emptyPatterns

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

  private val transformer: TableRowTransformer[T] = (row: JavaList[String]) => {
    details.body.transform(
      row.asScala
        .map(replaceEmptyPatternsWithEmptyString)
        .map(Option.apply)
        .toSeq
    )
  }

  override val dataTableType =
    new DataTableType(details.tag.runtimeClass, transformer)

}

class ScalaScenarioScopedDataTableOptionalRowDefinition[T](
    override val details: ScalaDataTableOptionalRowTypeDetails[T]
) extends ScalaDataTableOptionalRowDefinition[T]
    with ScenarioScoped {}

class ScalaGlobalDataTableOptionalRowDefinition[T](
    override val details: ScalaDataTableOptionalRowTypeDetails[T]
) extends ScalaDataTableOptionalRowDefinition[T] {}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy