diff --git a/src/test/resources/features/book.feature b/src/test/resources/features/book.feature index 03a9b0a..927180d 100644 --- a/src/test/resources/features/book.feature +++ b/src/test/resources/features/book.feature @@ -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 j’envoie 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 l’ID 9783161484100 existe - When j’envoie 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 j’envoie 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 j’envoie 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 qu’un livre avec l’ISBN 9783161484100 existe déjà dans le système - When j’envoie 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 qu’un livre avec l’ISBN 9783161484100 existe dans le système - When j’envoie 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 | \ No newline at end of file + 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 \ No newline at end of file diff --git a/src/test/resources/features/order.feature b/src/test/resources/features/order.feature index d3c7a8b..a457139 100644 --- a/src/test/resources/features/order.feature +++ b/src/test/resources/features/order.feature @@ -1,53 +1,56 @@ # language: en -Feature: Gestion des commandes - Backgroud: - Given Le systéme possède comme commande : +Feature: Manage orders + Background: - Given Le système possède comme commande: + Given the system has the following customers: + | id | firstName | lastName | phoneNumber | loyaltyPoints | + | 22222222-2222-2222-2222-222222222222 | Bob | Brown | 0600000002 | 200 | + And the system has the following books: + | isbn | title | author | publisher | publicationDate | price | quantity | language | + | 978222222 | Book A | Author A | PubA | 2021-01-01 | 12.0 | 10 | EN | + And the system has the following orders: + | id | customerId | totalPrice | paymentMethod | + | ord-1 | 22222222-2222-2222-2222-222222222222 | 24.0 | CREDIT_CARD | + Scenario: Create a new order + When I create a new order with the following information: + | customerId | paymentMethod | orderLineDtos | addressStreet | addressCity | addressPostalCode | addressCountry | + | 22222222-2222-2222-2222-222222222222 | CREDIT_CARD | [{ "bookId":978222222, "quantity":2 }] | 1 Main St | Paris | 75000 | France | + Then the order is created successfully + And the system now has 2 orders - Scenario: Créer une commande avec succès - Given un client avec l'identifiant "12345678-9101-1121-3141-516171819201" passe commande - And un livre avec l'identifiant 100 est en stock - And les détails de la commande sont : + Scenario: Get order by ID + When I request the order with id "ord-1" + Then I receive the following order information: + | id | customerId | totalPrice | paymentMethod | + | ord-1 | 22222222-2222-2222-2222-222222222222 | 24.0 | CREDIT_CARD | - When j'envoie une requête POST vers "/api/orders" avec ces informations - Then le code de réponse doit être 201 - And la réponse JSON doit contenir : - | customerId | 12345678-9101-1121-3141-516171819201 | - | paymentMethod | CREDIT_CARD | + Scenario: Attempt to create an order with insufficient book quantity + When I try to create a new order with the following information: + | customerId | paymentMethod | orderLineDtos | addressStreet | addressCity | addressPostalCode | addressCountry | + | 22222222-2222-2222-2222-222222222222 | CREDIT_CARD | [{ "bookId":978222222, "quantity":20 }] | 1 Main St | Paris | 75000 | France | + Then the creation fails + And I receive an error message containing "book quantity insufficient" + And the system still has 1 order - Scenario: Échec de la création d'une commande avec des données invalides - Given les détails de la commande sont : - | bookId | 9783161484100 | - | quantity | -10 | - | customerId | 12345678-9101-1121-3141-516171819201 | - | paymentMethod | rue des Tests | - | street | rue des Tests | - | city | Testville | - | postalCode | 12345 | - | country | France | + Scenario: Attempt to create an order with invalid details + When I try to create a new order with the following information: + | customerId | paymentMethod | orderLineDtos | addressStreet | addressCity | addressPostalCode | addressCountry | + | | | | | | | | + Then the creation fails + And I receive an error message containing "Invalid order details or address" + And the system still has 1 order - When l'utilisateur envoie une requête POST vers "/api/orders" - Then le code de réponse doit être 400 - And la réponse doit contenir le message : - | typeException | InvalidOrderException | - | errorMessage | Les détails de la commande sont invalides. | + Scenario: Attempt to create an order for unknown customer + When I try to create a new order with the following information: + | customerId | paymentMethod | orderLineDtos | addressStreet | addressCity | addressPostalCode | addressCountry | + | 99999999-9999-9999-9999-999999999999 | CREDIT_CARD | [{ "bookId":978222222, "quantity":2 }] | 1 Main St | Paris | 75000 | France | + Then the creation fails + And I receive an error message containing "Customer not found" + And the system still has 1 order - - Scenario: Échec de création de commande à cause d'un livre ou client introuvable - Given un identifiant client "client-inexistant" - And un identifiant livre "999999" qui n'existe pas - When j'envoie une requête POST vers "/api/orders" avec ces informations - Then le code de réponse doit être 404 - And la réponse JSON doit contenir : - | errorMessage | Book or customer not found | - - Scenario: Échec de commande à cause de points de fidélité ou de stock insuffisants - Given un client qui n'a pas assez de points de fidélité - And le livre commandé n'est pas disponible en quantité suffisante - When j'envoie une requête POST vers "/api/orders" - Then le code de réponse doit être 409 - And la réponse JSON doit contenir : - | errorMessage | Not enough loyalty points or book quantity insufficient | + Scenario: Attempt to get order by unknown ID + When I request the order with id "unknown-order-id" + Then the request fails + And I receive an error message containing "Order not found" \ No newline at end of file diff --git a/src/test/resources/features/review.feature b/src/test/resources/features/review.feature new file mode 100644 index 0000000..6fdf09f --- /dev/null +++ b/src/test/resources/features/review.feature @@ -0,0 +1,74 @@ +# language: en + +Feature: Manage reviews + + Background: + Given the system has the following customers: + | id | firstName | lastName | phoneNumber | loyaltyPoints | + | 33333333-3333-3333-3333-333333333333 | Carol | White | 0600000003 | 50 | + And the system has the following books: + | isbn | title | author | publisher | publicationDate | price | quantity | language | + | 978333333 | Book B | Author B | PubB | 2020-01-01 | 18.0 | 5 | EN | + And the system has the following reviews: + | reviewId | bookId | customerName | comment | rating | + | rev-1 | 978333333 | Carol White | Great book! | 5 | + + Scenario: Submit a new review + When I submit a new review with the following information: + | customerId | isbn | rating | comment | + | 33333333-3333-3333-3333-333333333333 | 978333333 | 4 | Enjoyed a lot! | + Then the review is created successfully + And the system now has 2 reviews + + Scenario: Get reviews by customer + When I request all reviews by customer "33333333-3333-3333-3333-333333333333" + Then I receive the following reviews: + | reviewId | bookId | customerName | comment | rating | + | rev-1 | 978333333 | Carol White | Great book! | 5 | + + Scenario: Attempt to submit a review for a book not purchased + When I try to submit a new review with the following information: + | customerId | isbn | rating | comment | + | 33333333-3333-3333-3333-333333333333 | 978333333 | 5 | Not purchased | + Then the submission fails + And I receive an error message containing "customer hasn't purchased the book" + And the system still has 1 review + + Scenario: Attempt to submit a review with invalid details + When I try to submit a new review with the following information: + | customerId | isbn | rating | comment | + | | | | | + Then the submission fails + And I receive an error message containing "Invalid review details" + And the system still has 1 review + + Scenario: Attempt to submit a review for unknown book or customer + When I try to submit a new review with the following information: + | customerId | isbn | rating | comment | + | 99999999-9999-9999-9999-999999999999 | 999999999 | 5 | Unknown book | + Then the submission fails + And I receive an error message containing "Book or customer not found" + And the system still has 1 review + + Scenario: Attempt to submit a duplicate review + When I try to submit a new review with the following information: + | customerId | isbn | rating | comment | + | 33333333-3333-3333-3333-333333333333 | 978333333 | 5 | Another review | + Then the submission fails + And I receive an error message containing "Review already exists" + And the system still has 1 review + + Scenario: Attempt to get reviews by unknown customer + When I request all reviews by customer "99999999-9999-9999-9999-999999999999" + Then the request fails + And I receive an error message containing "Book or customer not found" + + Scenario: Attempt to get reviews by unknown book + When I request all reviews for book "999999999" + Then the request fails + And I receive an error message containing "Book or customer not found" + + Scenario: Attempt to delete a review with unknown ID + When I try to delete the review with id "unknown-review-id" + Then the deletion fails + And I receive an error message containing "Review not found" \ No newline at end of file diff --git a/src/test/resources/features/subscription.feature b/src/test/resources/features/subscription.feature index 6102ab1..1cf2604 100644 --- a/src/test/resources/features/subscription.feature +++ b/src/test/resources/features/subscription.feature @@ -1,64 +1,53 @@ # language: en -Feature: Gestion des inscriptions de l'abonnement + +Feature: Manage subscriptions + Background: - Given Le systéme possède comme commande: - | durationInMonths | paymentMethod | requestedStartDate | customerId | - | 12 | CREDIT_CARD | 2025-01-01 | 00000000-0000-0000-0000-000000000000 | + Given the system has the following customers: + | id | firstName | lastName | phoneNumber | loyaltyPoints | + | 11111111-1111-1111-1111-111111111111 | Alice | Smith | 0600000001 | 100 | + And the system has the following subscriptions: + | subscriptionId | customerId | durationInMonths | startDate | endDate | + | sub-1 | 11111111-1111-1111-1111-111111111111 | 12 | 2023-01-01 | 2023-12-31 | - Scenario: Créer un abonnement avec succès - Given un client avec l’ID "12345678-9101-1121-3141-516171819201" s'inscrit à l'abonement - When j’envoie une requête POST vers "/api/subscriptions": - | durationInMonths | 6 | - | paymentMethod | CREDIT_CARD | - | requestedStartDate | 2025-01-01 | - | customerId | 12345678-9101-1121-3141-516171819201 | + Scenario: Request a new subscription + When I request a new subscription with the following information: + | customerId | durationInMonths | paymentMethod | requestedStartDate | + | 11111111-1111-1111-1111-111111111111 | 6 | CREDIT_CARD | 2024-01-01 | + Then the subscription is created successfully + And the system now has 2 subscriptions - Then le code de réponse doit être 201 - And la réponse doit contenir le champ "subscriptionId" + Scenario: Get customer's subscription + When I request the subscription for customer "11111111-1111-1111-1111-111111111111" + Then I receive the following subscription information: + | subscriptionId | customerId | durationInMonths | startDate | endDate | + | sub-1 | 11111111-1111-1111-1111-111111111111 | 12 | 2023-01-01 | 2023-12-31 | - Scenario: Échec de création à cause de données invalides - When j’envoie une requête POST vers "/api/subscriptions": - | customerId | gdftrg | - | durationInMonths | 0 | - | paymentMethod | AUTRE | - Then le code de réponse doit être 400 - And la réponse doit contenir : - | errorMessage | Invalid subscription details or payment method | + Scenario: Attempt to request a subscription with not enough loyalty points + When I try to request a new subscription with the following information: + | customerId | durationInMonths | paymentMethod | requestedStartDate | + | 11111111-1111-1111-1111-111111111111 | 12 | LOYALTY_POINTS | 2024-01-01 | + Then the request fails + And I receive an error message containing "Not enough loyalty points" + And the system still has 1 subscription - Scenario: Échec de création car le client est introuvable - When j’envoie une requête POST vers "/api/subscriptions": - | durationInMonths | 6 | - | paymentMethod | CREDIT_CARD | - | requestedStartDate | 2025-07-01 | - | customerId | 00000000-0000-0000-0000-000000000022 | - Then le code de réponse doit être 404 - And la réponse doit contenir : - | errorMessage | Customer not found | + Scenario: Attempt to request a subscription with invalid details + When I try to request a new subscription with the following information: + | customerId | durationInMonths | paymentMethod | requestedStartDate | + | | | | | + Then the request fails + And I receive an error message containing "Invalid subscription details or payment method" + And the system still has 1 subscription - Scenario: Échec de création customer "65464646" à cause de points de fidélité insuffisants - Given qu’un client avec l’ID "12345678-9101-1121-3141-516171819201" mais il n'a pas assez de points - When j’envoie une requête POST vers "/api/subscriptions": - | durationInMonths | 12 | - | paymentMethod | LOYALTY_POINTS | - | requestedStartDate | 2025-07-01 | - | customerId | 123e4567-e89b-12d3-a456-426614174000 | - Then le code de réponse doit être 409 - And la réponse doit contenir : - | errorMessage | Not enough loyalty points | + Scenario: Attempt to request a subscription for unknown customer + When I try to request a new subscription with the following information: + | customerId | durationInMonths | paymentMethod | requestedStartDate | + | 99999999-9999-9999-9999-999999999999 | 6 | CREDIT_CARD | 2024-01-01 | + Then the request fails + And I receive an error message containing "Customer not found" + And the system still has 1 subscription - Scenario: Récupérer l’abonnement d’un client existant - Given Un client avec l’ID "00000000-0000-0000-0000-000000000000" possède un abonnement actif - When j’envoie une requête GET vers "/api/subscriptions/customer/123e4567-e89b-12d3-a456-426614174000" - Then le code de réponse doit être 200 - And la réponse doit contenir : - | customerId | 00000000-0000-0000-0000-000000000000 | - | durationInMonths | 6 | - | startDate | 2025-01-01 | - | endDate | 2025-01-02 | - - Scenario: Récupérer l’abonnement d’un client sans abonnement - Given qu’un client avec l’ID "12345678-9101-1121-3141-516171819201" n’a pas d’abonnement - When j’envoie une requête GET vers "/api/subscriptions/customer/12345678-9101-1121-3141-516171819201" - Then le code de réponse doit être 404 - And la réponse doit contenir 65489 : - | errorMessage | Subscription not found for the customer | \ No newline at end of file + Scenario: Attempt to get subscription for unknown customer + When I request the subscription for customer "99999999-9999-9999-9999-999999999999" + Then the request fails + And I receive an error message containing "Subscription not found for the customer" \ No newline at end of file