Skip to content

Remove deprecated tests #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scala/scala_2.11/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
<args>
<arg>-deprecation</arg>
<arg>-feature</arg>
<!-- Allow definition of implicit functions called views -->
<arg>-language:implicitConversions</arg>
</args>
<excludes>
<exclude>**/*.java</exclude>
Expand Down
2 changes: 2 additions & 0 deletions scala/scala_2.12/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
<arg>-deprecation</arg>
<!-- Emit warning and location for usages of features that should be imported explicitly. -->
<arg>-feature</arg>
<!-- Allow definition of implicit functions called views -->
<arg>-language:implicitConversions</arg>
</args>
<excludes>
<exclude>**/*.java</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunCukesTest
Original file line number Diff line number Diff line change
@@ -1,115 +1,41 @@
package tests.cukes

import java.lang.reflect.Type
import java.util
import java.util.{Locale, Map => JMap}

import com.fasterxml.jackson.databind.ObjectMapper
import io.cucumber.core.api.{TypeRegistry, TypeRegistryConfigurer}
import io.cucumber.cucumberexpressions.{ParameterByTypeTransformer, ParameterType, Transformer}
import io.cucumber.datatable.{DataTableType, TableCellByTypeTransformer, TableEntryByTypeTransformer, TableEntryTransformer}
import io.cucumber.scala.ScalaDsl
import tests.cukes.model.{Cukes, Person, Snake}

import scala.annotation.nowarn

@nowarn
class TypeRegistryConfiguration extends TypeRegistryConfigurer {
class TypeRegistryConfiguration extends ScalaDsl {

/**
* Transforms an ASCII snake into an object, for example:
*
* {{{
* ====> becomes Snake(length = 5, direction = 'east)
* ==> becomes Snake(length = 3, direction = 'east)
* }}}
*/
private val snakeTransformer = new Transformer[Snake]() {
def transform(s: String) = {
val size = s.size
val direction = s.toList match {
case '<' :: _ => Symbol("west")
case l if l.last == '>' => Symbol("east")
}
Snake(size, direction)
}
}

private val personTransformer = new Transformer[Person]() {
def transform(s: String) = {
Person(s)
* Transforms an ASCII snake into an object, for example:
*
* {{{
* ====> becomes Snake(length = 5, direction = 'east)
* ==> becomes Snake(length = 3, direction = 'east)
* }}}
*/
ParameterType("snake", "[=><]+") { s =>
val size = s.length
val direction = s.toList match {
case '<' :: _ => Symbol("west")
case l if l.last == '>' => Symbol("east")
}
Snake(size, direction)
}

private val booleanTransformer = new Transformer[Boolean]() {
def transform(s: String) = {
s.trim.equals("true")
}
ParameterType("person", ".+") { s =>
Person(s)
}

private val charTransformer = new Transformer[Char]() {
def transform(s: String) = {
s.charAt(0)
}
}

private val listTransformer =new TableEntryTransformer[Cukes]() {
override def transform(map: util.Map[String, String]): Cukes = {
new Cukes(map.get("Number").toInt, map.get("Color"))
}
ParameterType("boolean", "true|false") { s =>
s.trim.equals("true")
}

override def locale(): Locale = Locale.ENGLISH

override def configureTypeRegistry(typeRegistry: TypeRegistry): Unit = {
val defaultTransformer = new DefaultTransformer()
typeRegistry.setDefaultDataTableCellTransformer(defaultTransformer)
typeRegistry.setDefaultDataTableEntryTransformer(defaultTransformer)
typeRegistry.setDefaultParameterTransformer(defaultTransformer)

typeRegistry.defineParameterType(new ParameterType[Snake](
"snake",
"[=><]+",
classOf[Snake],
snakeTransformer
))

typeRegistry.defineParameterType(new ParameterType[Person](
"person",
".+",
classOf[Person],
personTransformer
))

typeRegistry.defineParameterType(new ParameterType[Boolean](
"boolean",
"true|false",
classOf[Boolean],
booleanTransformer
))

typeRegistry.defineParameterType(new ParameterType[Char](
"char",
".",
classOf[Char],
charTransformer
))

typeRegistry.defineDataTableType(new DataTableType(classOf[Cukes],listTransformer))
ParameterType("char", ".") { s =>
s.charAt(0)
}
private class DefaultTransformer
extends ParameterByTypeTransformer
with TableEntryByTypeTransformer
with TableCellByTypeTransformer {

var objectMapper: ObjectMapper = new ObjectMapper()

override def transform(s: String, `type`: Type): AnyRef =
objectMapper.convertValue(s, objectMapper.constructType(`type`))

override def transform(map: JMap[String, String], `type`: Type, tableCellByTypeTransformer: TableCellByTypeTransformer): AnyRef = {
objectMapper.convertValue(map, objectMapper.constructType(`type`))
}

DataTableType { map: Map[String, String] =>
Cukes(map("Number").toInt, map("Color"))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunDatatablesTest
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunDocStringTest
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunIsolatedTest
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunJacksonTest
2 changes: 1 addition & 1 deletion scala/sources/src/test/scala/tests/misc/RunMiscTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunMiscTest
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunObjectTest
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import io.cucumber.junit.{Cucumber, CucumberOptions}
import org.junit.runner.RunWith

@RunWith(classOf[Cucumber])
@CucumberOptions(strict = true)
@CucumberOptions()
class RunParameterTypesTest