Files
mylibrary/src/test/resources/features/book.feature
2025-06-12 20:02:10 +02:00

54 lines
2.9 KiB
Gherkin

# language: en
Feature: Manage books
Background:
Given the system has the following books:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| 978123456 | The Odyssey | Homer | Penguin | 2000-01-01 | 10.0 | 5 | EN |
| 978654321 | War and Peace | Leo Tolstoy | Vintage | 2005-05-10 | 15.0 | 2 | EN |
Scenario: Register a new book
When I register a new book with the following information:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| 978111111 | New Book | New Author | NewPub | 2022-10-10 | 20.0 | 10 | EN |
Then the book is successfully registered
And the system now has 3 books
Scenario: Get all books
When I request all books
Then I receive the following books:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| 978123456 | The Odyssey | Homer | Penguin | 2000-01-01 | 10.0 | 5 | EN |
| 978654321 | War and Peace | Leo Tolstoy | Vintage | 2005-05-10 | 15.0 | 2 | EN |
Scenario: Get a book by ID
When I request the book with id 978123456
Then I receive the following book information:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| 978123456 | The Odyssey | Homer | Penguin | 2000-01-01 | 10.0 | 5 | EN |
Scenario: Attempt to register a book with invalid data
When I try to register a new book with the following information:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| | | | | | | | |
Then the registration fails
And I receive an error message containing "Invalid book data provided"
And the system still has 2 books
Scenario: Attempt to register a book with an existing ISBN
When I try to register a new book with the following information:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| 978123456 | The Odyssey | Homer | Penguin | 2000-01-01 | 10.0 | 5 | EN |
Then the registration fails
And I receive an error message containing "Conflict with existing book in database"
And the system still has 2 books
Scenario: Attempt to get a book with unknown ID
When I request the book with id 999999999
Then the request fails
And I receive an error message containing "Book not found"
Scenario: Attempt to get all books with a filter that matches nothing
When I request all books with title "Nonexistent Book"
Then I receive an empty list of books