Skip to content
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

DataTable does not support Kotlin Collection types #1838

Closed
mlvandijk opened this issue Dec 11, 2019 · 1 comment
Closed

DataTable does not support Kotlin Collection types #1838

mlvandijk opened this issue Dec 11, 2019 · 1 comment
Labels
🐛 bug Defect / Bug

Comments

@mlvandijk
Copy link
Member

mlvandijk commented Dec 11, 2019

Describe the bug
A clear and concise description of what the bug is.

When using Data Tables to pass a set of values to the StepDefs, the Kotlin types Map and List don't seem to be understood by TypeFactory.constructTypeInner(), resulting in the foollowing exception:
io.cucumber.datatable.UndefinedDataTableTypeException: Can't convert DataTable to Map<java.lang.String, ? extends java.util.Map<java.lang.String, java.lang.String>>. Please register a DataTableType with a TableEntryTransformer or TableCellTransformer for ? extends java.util.Map<java.lang.String, java.lang.String>

Using java.util.Map instead of kotlin.collections.Map fixes the problem

To Reproduce
Steps to reproduce the behavior:

  1. A step with a DataTable, for example:
Scenario Outline: Filter on status "<status>"
    Given orders with an order item and the following attributes:
    |  | expected | quantityRequested | quantityShipped | 
    | 101  | Status.REGISTERED | 10 | 0 | 
    | 102  | Status.SHIPPED | 10 | 10 | 
  1. A StepDef (in Kotlin) expecting a Map<String, Map<String, String>>:
  @Given("orders with an order item and the following attributes:")
    fun statusFilterOrdersInEs(attributes: Map<String, Map<String, String>>)

This StepDef does not work.

Work around
The following StepDef does work:

@Given("orders with an order item and the following attributes:")
    fun statusFilterOrdersInEs(attributes: java.util.Map<String, java.util.Map<String, String>>)

(providing explicit Java types)

Expected behavior
DataTable should be translated into the expected types (Kotlin Collections).

Context & Motivation
We are using DataTables to set up state in our Kotlin service, in order to test logic in this service.

Screenshots
N/A

Your Environment

  • Versions used: cucumber-java8 v4.8.0 (with datatable v1.1.14). Can also be reproduced when using datatable v3.0.0 explicitly.
  • Operating System and version: MacOs Mojave
  • Build tool: IntelliJ / Maven / JUnit
  • Kotlin version: 1.3.61
  • Java version: 1.8

Additional context
Add any other context about the problem here.

@mlvandijk mlvandijk added the 🐛 bug Defect / Bug label Dec 11, 2019
@mlvandijk
Copy link
Member Author

Info from Slack, provided by @mpkorstanje:
I strongly suspect the problem is here:
https://github.com/cucumber/cucumber/blob/master/datatable/java/datatable/src/main/java/io/cucumber/datatable/TypeFactory.java#L63
datatable/java/datatable/src/main/java/io/cucumber/datatable/TypeFactory.java:63

        // We'll only care about exact matches for now. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

No branches or pull requests

1 participant