Following this example, I am converting Cucumber 3.x.x datatable configurer to Cucumber 4.2.0 using JacksonTableTransformer
but is saying it cannot be resolved to a type.
Feature
And I Enter My Regular Income Sources
| name | Salary |
| amount | 25000 |
| frequency | every 2 weeks |
And I Enter My Regular Expenses
| name | amount | frequency |
| Electricity | 5500 | Monthly |
| Water | 900 | Weekly |
| Internet | 1900 | Every 2 Weeks |
| Cable TV | 555 | Daily |
Configurer
import io.cucumber.datatable.dependency.com.fasterxml.jackson.databind.ObjectMapper;
public class Configurer implements TypeRegistryConfigurer {
@Override
public Locale locale() {
return Locale.ENGLISH;
}
@Override
public void configureTypeRegistry(TypeRegistry registry) {
// Just added these 2 lines for Cucumber 4.2.0
JacksonTableTransformer jacksonTableTransformer = new JacksonTableTransformer();
registry.setDefaultDataTableEntryTransformer(jacksonTableTransformer);
/*
* Maps DataTable with header row to multiple objects of Type<T>. Each row below
* the header is an object.
*/
registry.defineDataTableType(new DataTableType(Transaction.class, new TableEntryTransformer<Transaction>() {
@Override
public Transaction transform(Map<String, String> entry) {
return new Transaction(entry);
}
}));
/*
* Maps DataTable with label column to a single object of Type<T>. Left column
* is field name, right column is value.
*/
registry.defineDataTableType(new DataTableType(Transaction.class, new TableTransformer<Transaction>() {
@Override
public Transaction transform(DataTable table) throws Throwable {
return new Transaction(table.asMaps().get(0));
}
}));
}
}
I only have 2 datatables and the configurer works for 3.x.x and 4.x.x if I remove the 2 lines added. I do want to use the object mapper though.
Following this example, I am converting Cucumber 3.x.x datatable configurer to Cucumber 4.2.0 using JacksonTableTransformer but is saying it cannot be resolved to a type.
If you read the full class file that you linked you'll find that JacksonTableTransformer is defined at line 99. I.e. you will have to define this class yourself.