forked from pierront/mylibrary-template
		
	Fichier feature
This commit is contained in:
		@@ -1,91 +1,54 @@
 | 
				
			|||||||
# language: en
 | 
					# language: en
 | 
				
			||||||
Feature: Gestion des livres
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Backgroud:
 | 
					Feature: Manage books
 | 
				
			||||||
  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        |
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Scenario: Récupérer tous les livres avec pagination
 | 
					  Background:
 | 
				
			||||||
    When j’envoie une requête GET vers "/api/books?page=0&size=10"
 | 
					    Given the system has the following books:
 | 
				
			||||||
    Then le code de réponse doit être 200
 | 
					      | isbn      | title           | author        | publisher   | publicationDate | price | quantity | language |
 | 
				
			||||||
    And la réponse doit contenir le champ "content"
 | 
					      | 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
 | 
					  Scenario: Register a new book
 | 
				
			||||||
    Given que le livre avec l’ID 9783161484100 existe
 | 
					    When I register a new book with the following information:
 | 
				
			||||||
    When j’envoie une requête GET vers "/api/books/9783161484100"
 | 
					      | isbn      | title         | author      | publisher | publicationDate | price | quantity | language |
 | 
				
			||||||
    Then le code de réponse doit être 200
 | 
					      | 978111111 | New Book      | New Author  | NewPub    | 2022-10-10      | 20.0  | 10       | EN       |
 | 
				
			||||||
    And la réponse doit contenir :
 | 
					    Then the book is successfully registered
 | 
				
			||||||
      | isbn            | 9783161484100      |
 | 
					    And the system now has 3 books
 | 
				
			||||||
      | 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: Ajouter un nouveau livre
 | 
					  Scenario: Get all books
 | 
				
			||||||
    When j’envoie une requête POST vers "/api/books" :
 | 
					    When I request all books
 | 
				
			||||||
      | isbn            | 66666666666666  |
 | 
					    Then I receive the following books:
 | 
				
			||||||
      | title           | Le Grand Roi    |
 | 
					      | isbn      | title           | author        | publisher   | publicationDate | price | quantity | language |
 | 
				
			||||||
      | author          | Saint de Exupery |
 | 
					      | 978123456 | The Odyssey     | Homer         | Penguin     | 2000-01-01      | 10.0  | 5        | EN       |
 | 
				
			||||||
      | publisher       | Mard            |
 | 
					      | 978654321 | War and Peace   | Leo Tolstoy   | Vintage     | 2005-05-10      | 15.0  | 2        | EN       |
 | 
				
			||||||
      | 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: Ajouter un nouveau livre mais cela cause l'erreur 400 à cause d'une mauvaise entrée
 | 
					  Scenario: Get a book by ID
 | 
				
			||||||
    When j’envoie une requête POST vers "/api/books" mais je met des informations incorrect:
 | 
					    When I request the book with id 978123456
 | 
				
			||||||
      | isbn            | 0000000000000            |
 | 
					    Then I receive the following book information:
 | 
				
			||||||
      | title           | Le Petit Prince          |
 | 
					      | isbn      | title       | author | publisher | publicationDate | price | quantity | language |
 | 
				
			||||||
      | author          | Antoine de Saint-Exupery |
 | 
					      | 978123456 | The Odyssey | Homer  | Penguin   | 2000-01-01      | 10.0  | 5        | EN       |
 | 
				
			||||||
      | 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: Ajouter un livre déjà existant
 | 
					  Scenario: Attempt to register a book with invalid data
 | 
				
			||||||
    Given qu’un livre avec l’ISBN 9783161484100 existe déjà dans le système
 | 
					    When I try to register a new book with the following information:
 | 
				
			||||||
    When j’envoie une requête POST vers "/api/books" d'un livre qui existe déjà:
 | 
					      | isbn      | title | author | publisher | publicationDate | price | quantity | language |
 | 
				
			||||||
      | isbn            | 9783161484100     |
 | 
					      |           |       |        |           |                |      |          |          |
 | 
				
			||||||
      | title           | Le Petit Prince   |
 | 
					    Then the registration fails
 | 
				
			||||||
      | author          | Antoine de Saint-Exupery  |
 | 
					    And I receive an error message containing "Invalid book data provided"
 | 
				
			||||||
      | publisher       | Gallimard         |
 | 
					    And the system still has 2 books
 | 
				
			||||||
      | 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: Récupérer un livre existant par son ID
 | 
					  Scenario: Attempt to register a book with an existing ISBN
 | 
				
			||||||
    Given qu’un livre avec l’ISBN 9783161484100 existe dans le système
 | 
					    When I try to register a new book with the following information:
 | 
				
			||||||
    When j’envoie une requête GET vers "/api/books/9783161484100"
 | 
					      | isbn      | title         | author      | publisher | publicationDate | price | quantity | language |
 | 
				
			||||||
    Then le code de réponse doit être 200
 | 
					      | 978123456 | The Odyssey   | Homer       | Penguin   | 2000-01-01      | 10.0  | 5        | EN       |
 | 
				
			||||||
    And la réponse doit contenir :
 | 
					    Then the registration fails
 | 
				
			||||||
      | isbn             | 9783161484100              |
 | 
					    And I receive an error message containing "Conflict with existing book in database"
 | 
				
			||||||
      | title            | Le Petit Prince            |
 | 
					    And the system still has 2 books
 | 
				
			||||||
      | author           | Antoine de Saint-Exupery   |
 | 
					
 | 
				
			||||||
      | publisher        | Gallimard                  |
 | 
					  Scenario: Attempt to get a book with unknown ID
 | 
				
			||||||
      | publicationDate  | 1943-04-06                 |
 | 
					    When I request the book with id 999999999
 | 
				
			||||||
      | price            | 12.5                       |
 | 
					    Then the request fails
 | 
				
			||||||
      | quantity         | 100                        |
 | 
					    And I receive an error message containing "Book not found"
 | 
				
			||||||
      | language         | fr                         |
 | 
					
 | 
				
			||||||
 | 
					  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
 | 
				
			||||||
@@ -1,53 +1,56 @@
 | 
				
			|||||||
# language: en
 | 
					# language: en
 | 
				
			||||||
Feature: Gestion des commandes
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Backgroud:
 | 
					Feature: Manage orders
 | 
				
			||||||
    Given Le systéme possède comme commande :
 | 
					
 | 
				
			||||||
  Background:
 | 
					  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
 | 
					  Scenario: Get order by ID
 | 
				
			||||||
    Given un client avec l'identifiant "12345678-9101-1121-3141-516171819201" passe commande
 | 
					    When I request the order with id "ord-1"
 | 
				
			||||||
    And un livre avec l'identifiant 100 est en stock
 | 
					    Then I receive the following order information:
 | 
				
			||||||
    And les détails de la commande sont :
 | 
					      | 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
 | 
					  Scenario: Attempt to create an order with insufficient book quantity
 | 
				
			||||||
    Then le code de réponse doit être 201
 | 
					    When I try to create a new order with the following information:
 | 
				
			||||||
    And la réponse JSON doit contenir :
 | 
					      | customerId                             | paymentMethod  | orderLineDtos                                      | addressStreet | addressCity | addressPostalCode | addressCountry |
 | 
				
			||||||
      | customerId    | 12345678-9101-1121-3141-516171819201 |
 | 
					      | 22222222-2222-2222-2222-222222222222   | CREDIT_CARD    | [{ "bookId":978222222, "quantity":20 }]            | 1 Main St     | Paris       | 75000            | France        |
 | 
				
			||||||
      | paymentMethod | CREDIT_CARD                         |
 | 
					    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
 | 
					  Scenario: Attempt to create an order with invalid details
 | 
				
			||||||
    Given les détails de la commande sont :
 | 
					    When I try to create a new order with the following information:
 | 
				
			||||||
        | bookId     | 9783161484100 |
 | 
					      | customerId | paymentMethod | orderLineDtos | addressStreet | addressCity | addressPostalCode | addressCountry |
 | 
				
			||||||
        | quantity   | -10           |
 | 
					      |            |              |               |              |             |                   |               |
 | 
				
			||||||
        | customerId | 12345678-9101-1121-3141-516171819201 |
 | 
					    Then the creation fails
 | 
				
			||||||
        | paymentMethod | rue des Tests |
 | 
					    And I receive an error message containing "Invalid order details or address"
 | 
				
			||||||
        | street     | rue des Tests |
 | 
					    And the system still has 1 order
 | 
				
			||||||
        | city       | Testville     |
 | 
					 | 
				
			||||||
        | postalCode | 12345         |
 | 
					 | 
				
			||||||
        | country    | France        |
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    When l'utilisateur envoie une requête POST vers "/api/orders"
 | 
					  Scenario: Attempt to create an order for unknown customer
 | 
				
			||||||
    Then le code de réponse doit être 400
 | 
					    When I try to create a new order with the following information:
 | 
				
			||||||
    And la réponse doit contenir le message :
 | 
					      | customerId                             | paymentMethod  | orderLineDtos                                      | addressStreet | addressCity | addressPostalCode | addressCountry |
 | 
				
			||||||
      | typeException | InvalidOrderException |
 | 
					      | 99999999-9999-9999-9999-999999999999   | CREDIT_CARD    | [{ "bookId":978222222, "quantity":2 }]             | 1 Main St     | Paris       | 75000            | France        |
 | 
				
			||||||
      | errorMessage  | Les détails de la commande sont invalides. |
 | 
					    Then the creation fails
 | 
				
			||||||
 | 
					    And I receive an error message containing "Customer not found"
 | 
				
			||||||
 | 
					    And the system still has 1 order
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Scenario: Attempt to get order by unknown ID
 | 
				
			||||||
  Scenario: Échec de création de commande à cause d'un livre ou client introuvable
 | 
					    When I request the order with id "unknown-order-id"
 | 
				
			||||||
    Given un identifiant client "client-inexistant"
 | 
					    Then the request fails
 | 
				
			||||||
    And un identifiant livre "999999" qui n'existe pas
 | 
					    And I receive an error message containing "Order not found"
 | 
				
			||||||
    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 |
 | 
					 | 
				
			||||||
							
								
								
									
										74
									
								
								src/test/resources/features/review.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								src/test/resources/features/review.feature
									
									
									
									
									
										Normal file
									
								
							@@ -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"
 | 
				
			||||||
@@ -1,64 +1,53 @@
 | 
				
			|||||||
# language: en
 | 
					# language: en
 | 
				
			||||||
Feature: Gestion des inscriptions de l'abonnement
 | 
					
 | 
				
			||||||
 | 
					Feature: Manage subscriptions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Background:
 | 
					  Background:
 | 
				
			||||||
    Given Le systéme possède comme commande:
 | 
					    Given the system has the following customers:
 | 
				
			||||||
      | durationInMonths | paymentMethod | requestedStartDate | customerId                           |
 | 
					      | id                                   | firstName | lastName | phoneNumber | loyaltyPoints |
 | 
				
			||||||
      | 12                | CREDIT_CARD  |  2025-01-01        | 00000000-0000-0000-0000-000000000000 |
 | 
					      | 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
 | 
					  Scenario: Request a new subscription
 | 
				
			||||||
  Given un client avec l’ID "12345678-9101-1121-3141-516171819201" s'inscrit à l'abonement
 | 
					    When I request a new subscription with the following information:
 | 
				
			||||||
  When j’envoie une requête POST vers "/api/subscriptions":
 | 
					      | customerId                             | durationInMonths | paymentMethod  | requestedStartDate |
 | 
				
			||||||
        | durationInMonths   | 6           |
 | 
					      | 11111111-1111-1111-1111-111111111111   | 6                | CREDIT_CARD    | 2024-01-01        |
 | 
				
			||||||
        | paymentMethod      | CREDIT_CARD |
 | 
					    Then the subscription is created successfully
 | 
				
			||||||
        | requestedStartDate | 2025-01-01  |
 | 
					    And the system now has 2 subscriptions
 | 
				
			||||||
        | customerId         | 12345678-9101-1121-3141-516171819201 |
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Then le code de réponse doit être 201
 | 
					  Scenario: Get customer's subscription
 | 
				
			||||||
  And la réponse doit contenir le champ "subscriptionId"
 | 
					    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
 | 
					  Scenario: Attempt to request a subscription with not enough loyalty points
 | 
				
			||||||
  When j’envoie une requête POST vers "/api/subscriptions":
 | 
					    When I try to request a new subscription with the following information:
 | 
				
			||||||
    | customerId       | gdftrg |
 | 
					      | customerId                             | durationInMonths | paymentMethod   | requestedStartDate |
 | 
				
			||||||
    | durationInMonths | 0      |
 | 
					      | 11111111-1111-1111-1111-111111111111   | 12               | LOYALTY_POINTS  | 2024-01-01        |
 | 
				
			||||||
    | paymentMethod    | AUTRE  |
 | 
					    Then the request fails
 | 
				
			||||||
  Then le code de réponse doit être 400
 | 
					    And I receive an error message containing "Not enough loyalty points"
 | 
				
			||||||
  And la réponse doit contenir :
 | 
					    And the system still has 1 subscription
 | 
				
			||||||
    | errorMessage   | Invalid subscription details or payment method |
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Scenario: Échec de création car le client est introuvable
 | 
					  Scenario: Attempt to request a subscription with invalid details
 | 
				
			||||||
  When j’envoie une requête POST vers "/api/subscriptions":
 | 
					    When I try to request a new subscription with the following information:
 | 
				
			||||||
    | durationInMonths   | 6           |
 | 
					      | customerId | durationInMonths | paymentMethod | requestedStartDate |
 | 
				
			||||||
    | paymentMethod      | CREDIT_CARD |
 | 
					      |            |                  |               |                   |
 | 
				
			||||||
    | requestedStartDate | 2025-07-01  |
 | 
					    Then the request fails
 | 
				
			||||||
    | customerId         | 00000000-0000-0000-0000-000000000022 |
 | 
					    And I receive an error message containing "Invalid subscription details or payment method"
 | 
				
			||||||
    Then le code de réponse doit être 404
 | 
					    And the system still has 1 subscription
 | 
				
			||||||
    And la réponse doit contenir :
 | 
					 | 
				
			||||||
      | errorMessage  | Customer not found |
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Scenario: Échec de création customer "65464646" à cause de points de fidélité insuffisants
 | 
					  Scenario: Attempt to request a subscription for unknown customer
 | 
				
			||||||
    Given qu’un client avec l’ID "12345678-9101-1121-3141-516171819201" mais il n'a pas assez de points
 | 
					    When I try to request a new subscription with the following information:
 | 
				
			||||||
    When j’envoie une requête POST vers "/api/subscriptions":
 | 
					      | customerId                             | durationInMonths | paymentMethod  | requestedStartDate |
 | 
				
			||||||
      | durationInMonths   | 12             |
 | 
					      | 99999999-9999-9999-9999-999999999999   | 6                | CREDIT_CARD    | 2024-01-01        |
 | 
				
			||||||
      | paymentMethod      | LOYALTY_POINTS |
 | 
					    Then the request fails
 | 
				
			||||||
      | requestedStartDate | 2025-07-01     |
 | 
					    And I receive an error message containing "Customer not found"
 | 
				
			||||||
      | customerId         | 123e4567-e89b-12d3-a456-426614174000 |
 | 
					    And the system still has 1 subscription
 | 
				
			||||||
    Then le code de réponse doit être 409
 | 
					 | 
				
			||||||
    And la réponse doit contenir :
 | 
					 | 
				
			||||||
      | errorMessage  | Not enough loyalty points |
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Scenario: Récupérer l’abonnement d’un client existant
 | 
					  Scenario: Attempt to get subscription for unknown customer
 | 
				
			||||||
    Given Un client avec l’ID "00000000-0000-0000-0000-000000000000" possède un abonnement actif
 | 
					    When I request the subscription for customer "99999999-9999-9999-9999-999999999999"
 | 
				
			||||||
    When j’envoie une requête GET vers "/api/subscriptions/customer/123e4567-e89b-12d3-a456-426614174000"
 | 
					    Then the request fails
 | 
				
			||||||
    Then le code de réponse doit être 200
 | 
					    And I receive an error message containing "Subscription not found for the customer"
 | 
				
			||||||
    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 |
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user