[BAEL-3445] Added Background examples to Cucumber examples (#8319)
This commit is contained in:
+9
-7
@@ -1,13 +1,9 @@
|
||||
package com.baeldung.cucumber.books;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BookStore {
|
||||
|
||||
private List<Book> books = new ArrayList<>();
|
||||
|
||||
public void addBook(Book book) {
|
||||
@@ -20,7 +16,13 @@ public class BookStore {
|
||||
|
||||
public List<Book> booksByAuthor(String author) {
|
||||
return books.stream()
|
||||
.filter(book -> Objects.equals(author, book.getAuthor()))
|
||||
.collect(Collectors.toList());
|
||||
.filter(book -> Objects.equals(author, book.getAuthor()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Optional<Book> bookByTitle(String title) {
|
||||
return books.stream()
|
||||
.filter(book -> book.getTitle().equals(title))
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user