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

Update to Cucumber 4.x.x #137

Open
kathyrollo opened this issue Nov 14, 2018 · 3 comments
Open

Update to Cucumber 4.x.x #137

kathyrollo opened this issue Nov 14, 2018 · 3 comments
Assignees
Labels
dependency fix This requires a fix for a dependency enhancement New feature or request
Milestone

Comments

@kathyrollo kathyrollo added enhancement New feature or request slow burner This can be done at a later time labels Nov 14, 2018
@kathyrollo kathyrollo self-assigned this Nov 14, 2018
@kathyrollo kathyrollo added this to the version4 milestone Nov 14, 2018
@kathyrollo kathyrollo removed the slow burner This can be done at a later time label Dec 16, 2018
@kathyrollo kathyrollo added the dependency fix This requires a fix for a dependency label Jun 22, 2019
@kathyrollo
Copy link
Owner Author

@kathyrollo kathyrollo pinned this issue Jun 22, 2019
@kathyrollo
Copy link
Owner Author

kathyrollo commented Jun 28, 2019

Configurer.java (3.x.x)

Compatible with Cucumber 4.x.x

package project.datatables;

import java.util.Locale;
import java.util.Map;

import cucumber.api.TypeRegistry;
import cucumber.api.TypeRegistryConfigurer;
import io.cucumber.datatable.DataTable;
import io.cucumber.datatable.DataTableType;
import io.cucumber.datatable.TableEntryTransformer;
import io.cucumber.datatable.TableTransformer;
import project.dataobjects.Transaction;

public class Configurer implements TypeRegistryConfigurer {

	@Override
	public Locale locale() {
		return Locale.ENGLISH;
	}

	@Override
	public void configureTypeRegistry(TypeRegistry registry) {

		/*
		 * 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 Transaction.getInstance(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 Transaction.getInstance(table.asMaps().get(0));
			}
		}));

	}

}

@kathyrollo
Copy link
Owner Author

Cucumber 4.x.x

Official Doc: https://cucumber.io/docs/cucumber/configuration/#type-registry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency fix This requires a fix for a dependency enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant