Fichier feature

This commit is contained in:
Kroccmou
2025-06-12 20:02:10 +02:00
parent 0b1d59390f
commit c7230c889e
4 changed files with 212 additions and 183 deletions

View File

@@ -1,91 +1,54 @@
# language: en
Feature: Gestion des livres
Backgroud:
Given Le systéme possède comme livre :
| isbn | title | author | publisher | publicationDate | price | quantity | categories | description | language |
| 999 | Bob | Boby | Nathan | 2025-06-12 | 1.5 | 0 | FICTION, THRILLER | blabla | fr |
| 9783161484100 | Le Petit Prince | Antoine de Saint-Exupery | Gallimard | 1943-04-06 | 12.5 | 100 | FICTION, CHILDRENS | un conte poetique et philosophique | fr |
Feature: Manage books
Scenario: Récupérer tous les livres avec pagination
When jenvoie une requête GET vers "/api/books?page=0&size=10"
Then le code de réponse doit être 200
And la réponse doit contenir le champ "content"
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: Récupérer un livre par son identifiant
Given que le livre avec lID 9783161484100 existe
When jenvoie une requête GET vers "/api/books/9783161484100"
Then le code de réponse doit être 200
And la réponse doit contenir :
| isbn | 9783161484100 |
| title | Le Petit Prince |
| author | Antoine de Saint-Exupery |
| publisher | Gallimard |
| publicationDate | 1943-04-06 |
| price | 12.5 |
| quantity | 100 |
| categories | FICTION,CHILDRENS |
| description | Un conte poetique et philosophique |
| language | fr |
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: Ajouter un nouveau livre
When jenvoie une requête POST vers "/api/books" :
| isbn | 66666666666666 |
| title | Le Grand Roi |
| author | Saint de Exupery |
| publisher | Mard |
| publicationDate | 1993-06-06 |
| price | 10.5 |
| quantity | 15 |
| categories | FICTION |
| description | Un conte |
| language | fr |
Then le code de réponse doit être 201
And le systéme doit avoir 3 livres
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: Ajouter un nouveau livre mais cela cause l'erreur 400 à cause d'une mauvaise entrée
When jenvoie une requête POST vers "/api/books" mais je met des informations incorrect:
| isbn | 0000000000000 |
| title | Le Petit Prince |
| author | Antoine de Saint-Exupery |
| publisher | Gallimard |
| publicationDate | 19430406 |
| price | -12.5 |
| quantity | 100 |
| categories | TeSt |
| description | Un conte poetique et philosophique |
| language | fr |
Then le code de réponse doit être 400
And la réponse doit contenir le message :
| typeException | BadRequestException |
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: Ajouter un livre déjà existant
Given quun livre avec lISBN 9783161484100 existe déjà dans le système
When jenvoie une requête POST vers "/api/books" d'un livre qui existe déjà:
| isbn | 9783161484100 |
| title | Le Petit Prince |
| author | Antoine de Saint-Exupery |
| publisher | Gallimard |
| publicationDate | 1943-04-06 |
| price | 12.5 |
| quantity | 100 |
| categories | FICTION |
| description | Un conte poetique |
| language | fr |
Then le code de réponse doit être 406
And la réponse doit contenir :
| typeException | ConflictException |
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: Récupérer un livre existant par son ID
Given quun livre avec lISBN 9783161484100 existe dans le système
When jenvoie une requête GET vers "/api/books/9783161484100"
Then le code de réponse doit être 200
And la réponse doit contenir :
| isbn | 9783161484100 |
| title | Le Petit Prince |
| author | Antoine de Saint-Exupery |
| publisher | Gallimard |
| publicationDate | 1943-04-06 |
| price | 12.5 |
| quantity | 100 |
| language | fr |
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