You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package project.datatable;
import java.util.Locale;
import cucumber.api.TypeRegistry;
import cucumber.api.TypeRegistryConfigurer;
import io.cucumber.datatable.DataTable;
import io.cucumber.datatable.DataTableType;
import io.cucumber.datatable.TableTransformer;
import project.domain.Transaction;
/**
* Maps DataTable with label column in feature file to a single object of
* Type{@literal <T>}. Left column is field name, right column is value.
*/
public class TableConfigurer implements TypeRegistryConfigurer {
@Override
public Locale locale() {
return Locale.ENGLISH;
}
@Override
public void configureTypeRegistry(TypeRegistry registry) {
registry.defineDataTableType(new DataTableType(Transaction.class, new TableTransformer<Transaction>() {
@Override
public Transaction transform(DataTable dataTable) throws Throwable {
return new Transaction(dataTable.asMaps().get(0));
}
}));
}
}
TableEntryConfigurer.java:
package project.datatable;
import java.util.Locale;
import java.util.Map;
import cucumber.api.TypeRegistry;
import cucumber.api.TypeRegistryConfigurer;
import io.cucumber.datatable.DataTableType;
import io.cucumber.datatable.TableEntryTransformer;
import project.domain.Transaction;
/**
* Maps DataTable with header row in feature file to multiple objects of
* Type{@literal <T>}. Each row below the header is an object.
*/
public class TableEntryConfigurer implements TypeRegistryConfigurer {
@Override
public Locale locale() {
return Locale.ENGLISH;
}
@Override
public void configureTypeRegistry(TypeRegistry registry) {
registry.defineDataTableType(new DataTableType(Transaction.class, new TableEntryTransformer<Transaction>() {
@Override
public Transaction transform(Map<String, String> map) {
return new Transaction(map.get("name"), map.get("amount"), map.get("frequency"), map.get("month"));
}
}));
}
}
The text was updated successfully, but these errors were encountered:
Implement
TableConfigurer
andTableEntryConfigurer
for different DataTable types.Currently not supported:
cucumber/cucumber-jvm#1426
TableConfigurer.java:
TableEntryConfigurer.java:
The text was updated successfully, but these errors were encountered: