question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transformer doesn't convert "[empty]" values in the table to empty string ("")

See original GitHub issue

Describe the bug Updated to version 6.10.0 recently and went through the documentation https://github.com/cucumber/cucumber-jvm-scala/blob/main/docs/transformers.md but seems like none of the registered transformers for empty values in being used during the transformation. Not sure at what stage the transformer is called or if I’m doing something wrong.

Registered the transformer defined as:

  DefaultDataTableCellTransformer("[empty]")((s: String, t: java.lang.reflect.Type) => {
    new StringBuilder().append(s).append("-").append(t)
  })

and can see it’s being registered (see attached screenshot) with glue but after transformation the DataTable values are still coming out to be [empty].

To Reproduce Steps to reproduce the behavior.

  Scenario: Test case 2, hotel with special condition
    Given Hotels 419 checkin 2020-10-01 los 2
    And BookingDate 2020-09-19 01:30:00
    And GMTOffset +7
    When The user search
    Then The cancellation policy from search result should match following expected value
      | RoomId     | Promotion | Description | DefaultDescription | FreeCancellationDate          | Title               | Symbol            |
      | 1199923528 | -         |  [empty]    |       [empty]      | 2020-09-19T00:00:00.000+07:00 | Cancellation policy | special-condition |

Step is defined as:

  Then("""^The search result should match following expected value$""") { (dt: DataTable) =>
    val result = parseResult(response, dataExtractors)
    validateResult(dt, result)
  }

Expected behavior I expected the cells in features marked with [empty would be converted to "" against which result can be validated.

Versions:

  • Cucumber Scala: [e.g. 6.10.0]
  • Scala: [e.g. 2.12]

Additional context Add any other context about the problem here.

Screen Shot 2021-03-11 at 14 26 04

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mpkorstanjecommented, Mar 12, 2021

It would make sense for all .asX methods to invoke the transformer though, currently the difference between .asList(String.class) and .asList() is somewhat unexpected. We can do this on the next major version of Cucumber JVM.

1reaction
mpkorstanjecommented, Mar 12, 2021

The transformers are only applied when the data table is converted into something else. The idea being that you use a list of transformed objects rather then a data table.

  Then("""^The search result should match following expected value$""") { 
      (cancelationPolicyResults: Seq[CancelationPolicyResult]) => ...

  }

Or if you use it on a list of strings, that you use a list of strings instead.

  Then("""^The search result should match following expected value$""") { 
      (cancelationPolicyResults: Seq[Seq[String]]) => ...

  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass empty string to cucumber DataTable - java - Stack Overflow
Since v5.0.0 empty cells in a data table are into null values rather than the empty string. By using replaceWithEmptyString = "[blank]" on...
Read more >
Null handling functions - IBM
Returns an empty string if the input column is null, otherwise returns the input column value. Examples. If the Derivation field for an...
Read more >
JDBC Receiver does not convert empty string to NULL
Hello experts, I am facing a problem with an INSERT statement to ORACLE DB where some of the fields are empty, for example:...
Read more >
Impala Type Conversion Functions
If the expression value is of a type that cannot be converted to the target type : ... If pattern is NULL ,...
Read more >
How Does FME Handle Null Attribute Values?
NullAttributeMapper – can be used to do bulk mapping of attribute values to/from null, missing, and empty strings. Many transformers have options for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found