diff --git a/testing-modules/testing-libraries/pom.xml b/testing-modules/testing-libraries/pom.xml
index 0838e81d14..521520833d 100644
--- a/testing-modules/testing-libraries/pom.xml
+++ b/testing-modules/testing-libraries/pom.xml
@@ -18,21 +18,22 @@
${lambda-behave.version}
- info.cukes
+ io.cucumber
cucumber-junit
- ${cucumber.version}
+ 4.8.0
test
- info.cukes
+ io.cucumber
cucumber-java
- ${cucumber.version}
+ 4.8.0
test
+
- info.cukes
+ io.cucumber
cucumber-java8
- ${cucumber.version}
+ 4.8.0
test
diff --git a/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/Book.java b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/Book.java
new file mode 100644
index 0000000000..f83623445b
--- /dev/null
+++ b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/Book.java
@@ -0,0 +1,35 @@
+package com.baeldung.cucumber.books;
+
+public class Book {
+
+ private String title;
+ private String author;
+
+ public Book(String title, String author) {
+ this.title = title;
+ this.author = author;
+ }
+
+ public Book() {}
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ @Override
+ public String toString() {
+ return "Book [title=" + title + ", author=" + author + "]";
+ }
+}
diff --git a/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/BookCatalog.java b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/BookCatalog.java
new file mode 100644
index 0000000000..69fa8e3160
--- /dev/null
+++ b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/BookCatalog.java
@@ -0,0 +1,22 @@
+package com.baeldung.cucumber.books;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BookCatalog {
+
+ private List books = new ArrayList<>();
+
+ public void addBook(Book book) {
+ books.add(book);
+ }
+
+ public List getBooks() {
+ return books;
+ }
+
+ @Override
+ public String toString() {
+ return "BookCatalog [books=" + books + "]";
+ }
+}
diff --git a/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/BookStore.java b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/BookStore.java
new file mode 100644
index 0000000000..e5a3ceab3e
--- /dev/null
+++ b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumber/books/BookStore.java
@@ -0,0 +1,26 @@
+package com.baeldung.cucumber.books;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+public class BookStore {
+
+ private List books = new ArrayList<>();
+
+ public void addBook(Book book) {
+ books.add(book);
+ }
+
+ public void addAllBooks(Collection books) {
+ this.books.addAll(books);
+ }
+
+ public List booksByAuthor(String author) {
+ return books.stream()
+ .filter(book -> Objects.equals(author, book.getAuthor()))
+ .collect(Collectors.toList());
+ }
+}
diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorIntegrationTest.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorIntegrationTest.java
index 00f666db2d..e4580900a2 100644
--- a/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorIntegrationTest.java
+++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorIntegrationTest.java
@@ -1,9 +1,10 @@
package com.baeldung.calculator;
-import cucumber.api.CucumberOptions;
-import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
+import io.cucumber.junit.Cucumber;
+import io.cucumber.junit.CucumberOptions;
+
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"classpath:features/calculator.feature", "classpath:features/calculator-scenario-outline.feature"}
diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorRunSteps.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorRunSteps.java
index 7eda618566..1bf0c0eccd 100644
--- a/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorRunSteps.java
+++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/calculator/CalculatorRunSteps.java
@@ -1,13 +1,15 @@
package com.baeldung.calculator;
-import com.baeldung.cucumber.Calculator;
-import cucumber.api.java.Before;
-import cucumber.api.java.en.Given;
-import cucumber.api.java.en.Then;
-import cucumber.api.java.en.When;
import org.hamcrest.Matchers;
import org.junit.Assert;
+import com.baeldung.cucumber.Calculator;
+
+import io.cucumber.java.Before;
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
+
public class CalculatorRunSteps {
private int total;
diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreIntegrationTest.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreIntegrationTest.java
new file mode 100644
index 0000000000..233fd3c489
--- /dev/null
+++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreIntegrationTest.java
@@ -0,0 +1,14 @@
+package com.baeldung.cucumber.books;
+
+import org.junit.runner.RunWith;
+
+import io.cucumber.junit.Cucumber;
+import io.cucumber.junit.CucumberOptions;
+
+
+@RunWith(Cucumber.class)
+@CucumberOptions(features = "classpath:features/book-store.feature")
+public class BookStoreIntegrationTest {
+
+}
+
diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRegistryConfigurer.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRegistryConfigurer.java
new file mode 100644
index 0000000000..e8e7e91994
--- /dev/null
+++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRegistryConfigurer.java
@@ -0,0 +1,44 @@
+package com.baeldung.cucumber.books;
+
+import java.util.Locale;
+
+import io.cucumber.core.api.TypeRegistry;
+import io.cucumber.core.api.TypeRegistryConfigurer;
+import io.cucumber.datatable.DataTable;
+import io.cucumber.datatable.DataTableType;
+import io.cucumber.datatable.TableTransformer;
+
+public class BookStoreRegistryConfigurer implements TypeRegistryConfigurer {
+
+ @Override
+ public Locale locale() {
+ return Locale.ENGLISH;
+ }
+
+ @Override
+ public void configureTypeRegistry(TypeRegistry typeRegistry) {
+ typeRegistry.defineDataTableType(new DataTableType(BookCatalog.class, new BookTableTransformer()));
+
+ }
+
+ private static class BookTableTransformer implements TableTransformer {
+
+ @Override
+ public BookCatalog transform(DataTable table) throws Throwable {
+
+ BookCatalog catalog = new BookCatalog();
+
+ table.cells()
+ .stream()
+ .skip(1) // Skip header row
+ .map(fields -> new Book(fields.get(0), fields.get(1)))
+ .forEach(catalog::addBook);
+
+ System.out.println(catalog);
+
+ return catalog;
+ }
+
+ }
+
+}
diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRunSteps.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRunSteps.java
new file mode 100644
index 0000000000..21901d913d
--- /dev/null
+++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumber/books/BookStoreRunSteps.java
@@ -0,0 +1,60 @@
+package com.baeldung.cucumber.books;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import io.cucumber.java.Before;
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
+import io.cucumber.datatable.DataTable;
+
+public class BookStoreRunSteps {
+
+ private BookStore store;
+ private List foundBooks;
+
+ @Before
+ public void setUp() {
+ store = new BookStore();
+ foundBooks = new ArrayList<>();
+ }
+
+ @Given("^I have the following books in the store by list$")
+ public void haveBooksInTheStoreByList(DataTable table) {
+
+ List> rows = table.asLists(String.class);
+
+ for (List fields: rows) {
+ store.addBook(new Book(fields.get(0), fields.get(1)));
+ }
+ }
+
+ @Given("^I have the following books in the store by map$")
+ public void haveBooksInTheStoreByMap(DataTable table) {
+
+ List