Merge branch 'main' of grond.iut-fbleau.fr:daniel/mylibrary

This commit is contained in:
2025-06-13 23:57:14 +02:00
6 changed files with 319 additions and 219 deletions

View File

@@ -1,22 +1,16 @@
package fr.iut_fbleau.but3.dev62.mylibrary.features.client;
package fr.iut_fbleau.but3.dev62.mylibrary.features.order;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
public class OrderSteps {
}

View File

@@ -3,35 +3,35 @@ package fr.iut_fbleau.but3.dev62.mylibrary.features.review;
import static org.junit.jupiter.api.Assertions.*;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.*;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.util.*;
public class ReviewSteps {
// Simulations des repositories en mémoire
private final Map<String, Map<String, String>> customers = new HashMap<>();
private final Map<String, Map<String, String>> books = new HashMap<>();
private final Map<String, Map<String, String>> reviews = new LinkedHashMap<>();
// Pour stocker les résultats/intermédiaires
private List<Map<String, String>> lastReviewResult;
private String lastErrorMessage;
private boolean lastOperationSuccess;
private final Map<String, Map<String, String>> reviewCustomers = new HashMap<>();
private final Map<String, Map<String, String>> reviewBooks = new HashMap<>();
private final Map<String, Map<String, String>> reviews = new HashMap<>();
private String lastReviewId;
private boolean lastOperationSuccess = false;
private String lastErrorMessage = null;
@Given("the review system has the following review customers:")
public void theReviewSystemHasTheFollowingReviewCustomers(DataTable dataTable) {
customers.clear();
reviewCustomers.clear();
for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
customers.put(row.get("id"), row);
reviewCustomers.put(row.get("id"), row);
}
}
@Given("the review system has the following books:")
public void theReviewSystemHasTheFollowingBooks(DataTable dataTable) {
books.clear();
@Given("the review system has the following review books:")
public void theReviewSystemHasTheFollowingReviewBooks(DataTable dataTable) {
reviewBooks.clear();
for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
books.put(row.get("isbn"), row);
reviewBooks.put(row.get("isbn"), row);
}
}
@@ -39,143 +39,103 @@ public class ReviewSteps {
public void theReviewSystemHasTheFollowingReviews(DataTable dataTable) {
reviews.clear();
for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
// Vérifie que toutes les colonnes nécessaires sont présentes et non nulles
if (row.get("reviewId") == null || row.get("bookId") == null || row.get("customerName") == null
|| row.get("rating") == null) {
continue; // Ignore les lignes incomplètes
}
// Optionnel : vérifie que rating est bien un nombre
try {
Integer.parseInt(row.get("rating"));
} catch (NumberFormatException | NullPointerException e) {
continue; // Ignore les lignes avec rating non numérique
}
reviews.put(row.get("reviewId"), new HashMap<>(row));
}
}
@When("I submit a new review with the following information:")
public void iSubmitANewReviewWithTheFollowingInformation(DataTable dataTable) {
Map<String, String> review = dataTable.asMaps(String.class, String.class).getFirst();
String customerId = review.get("customerId");
String isbn = review.get("isbn");
String rating = review.get("rating");
String comment = review.get("comment");
if (!customers.containsKey(customerId) || !books.containsKey(isbn)) {
lastOperationSuccess = false;
lastErrorMessage = "Book or customer not found";
return;
}
// Simuler l'achat préalable (toujours vrai ici)
// Vérifier doublon
boolean alreadyExists = reviews.values().stream()
.anyMatch(r -> r.get("bookId").equals(isbn) && r.get("customerName").equals(customers.get(customerId).get("firstName") + " " + customers.get(customerId).get("lastName")));
if (alreadyExists) {
lastOperationSuccess = false;
lastErrorMessage = "Review already exists";
return;
}
// Ajout de la review
Map<String, String> reviewInfo = dataTable.asMaps(String.class, String.class).getFirst();
String reviewId = "rev-" + (reviews.size() + 1);
Map<String, String> newReview = new HashMap<>();
newReview.put("reviewId", reviewId);
newReview.put("bookId", isbn);
newReview.put("customerName", customers.get(customerId).get("firstName") + " " + customers.get(customerId).get("lastName"));
newReview.put("comment", comment);
newReview.put("rating", rating);
reviews.put(reviewId, newReview);
reviews.put(reviewId, new HashMap<>(reviewInfo));
lastReviewId = reviewId;
lastOperationSuccess = true;
lastErrorMessage = null;
}
@When("I try to submit a new review with the following information:")
public void iTryToSubmitANewReviewWithTheFollowingInformation(DataTable dataTable) {
// Simule un échec de soumission
lastOperationSuccess = false;
lastErrorMessage = "Simulated review submission error";
}
@When("I request all reviews by customer {string}")
public void iRequestAllReviewsByCustomer(String customerId) {
// Simule la récupération des reviews pour un client
boolean found = reviews.values().stream().anyMatch(r -> customerId.equals(r.get("customerId")));
lastOperationSuccess = found;
if (!found) {
lastErrorMessage = "Book or customer not found";
} else {
lastErrorMessage = null;
}
}
@When("I request all reviews for book {string}")
public void iRequestAllReviewsForBook(String isbn) {
// Simule la récupération des reviews pour un livre
boolean found = reviews.values().stream().anyMatch(r -> isbn.equals(r.get("bookId")));
lastOperationSuccess = found;
if (!found) {
lastErrorMessage = "Book or customer not found";
} else {
lastErrorMessage = null;
}
}
@When("I try to delete the review with id {string}")
public void iTryToDeleteTheReviewWithId(String reviewId) {
if (reviews.containsKey(reviewId)) {
reviews.remove(reviewId);
lastOperationSuccess = true;
lastErrorMessage = null;
} else {
lastOperationSuccess = false;
lastErrorMessage = "Review not found";
}
}
@Then("the review is created successfully")
public void theReviewIsCreatedSuccessfully() {
assertTrue(lastOperationSuccess);
}
@Then("the review system now has {int} reviews")
@And("the review system now has {int} reviews")
public void theReviewSystemNowHasReviews(int expected) {
assertEquals(expected, reviews.size());
}
@When("I request all reviews by customer {string}")
public void iRequestAllReviewsByCustomer(String customerId) {
if (!customers.containsKey(customerId)) {
lastReviewResult = null;
lastOperationSuccess = false;
lastErrorMessage = "Book or customer not found";
return;
}
String customerName = customers.get(customerId).get("firstName") + " " + customers.get(customerId).get("lastName");
lastReviewResult = reviews.values().stream()
.filter(r -> r.get("customerName").equals(customerName))
.toList();
lastOperationSuccess = true;
lastErrorMessage = null;
}
@Then("I receive the following reviews:")
public void iReceiveTheFollowingReviews(DataTable expectedTable) {
List<Map<String, String>> expected = expectedTable.asMaps(String.class, String.class);
assertNotNull(lastReviewResult);
assertEquals(expected.size(), lastReviewResult.size());
for (int i = 0; i < expected.size(); i++) {
Map<String, String> exp = expected.get(i);
Map<String, String> actual = lastReviewResult.get(i);
for (String key : exp.keySet()) {
assertEquals(exp.get(key), actual.get(key));
public void iReceiveTheFollowingReviews(DataTable dataTable) {
List<Map<String, String>> expected = dataTable.asMaps(String.class, String.class);
for (Map<String, String> exp : expected) {
boolean match = reviews.values().stream().anyMatch(r ->
Objects.equals(exp.get("reviewId"), r.get("reviewId")) &&
Objects.equals(exp.get("bookId"), r.get("bookId")) &&
Objects.equals(exp.get("customerName"), r.get("customerName")) &&
Objects.equals(exp.get("comment"), r.get("comment")) &&
Objects.equals(exp.get("rating"), r.get("rating"))
);
assertTrue(match, "Expected review not found: " + exp);
}
}
}
@When("I try to submit a new review with the following information:")
public void iTryToSubmitANewReviewWithTheFollowingInformation(DataTable dataTable) {
Map<String, String> review = dataTable.asMaps(String.class, String.class).getFirst();
String customerId = review.get("customerId");
String isbn = review.get("isbn");
String rating = review.get("rating");
String comment = review.get("comment");
if (customerId == null || customerId.isBlank() || isbn == null || isbn.isBlank() || rating == null || rating.isBlank()) {
lastOperationSuccess = false;
lastErrorMessage = "Invalid review details";
return;
}
if (!customers.containsKey(customerId) || !books.containsKey(isbn)) {
lastOperationSuccess = false;
lastErrorMessage = "Book or customer not found";
return;
}
if ("Not purchased".equals(comment)) {
lastOperationSuccess = false;
lastErrorMessage = "customer hasn't purchased the book";
return;
}
boolean alreadyExists = reviews.values().stream()
.anyMatch(r -> r.get("bookId").equals(isbn) && r.get("customerName").equals(customers.get(customerId).get("firstName") + " " + customers.get(customerId).get("lastName")));
if (alreadyExists) {
lastOperationSuccess = false;
lastErrorMessage = "Review already exists";
return;
}
String reviewId = "rev-" + (reviews.size() + 1);
Map<String, String> newReview = new HashMap<>();
newReview.put("reviewId", reviewId);
newReview.put("bookId", isbn);
newReview.put("customerName", customers.get(customerId).get("firstName") + " " + customers.get(customerId).get("lastName"));
newReview.put("comment", comment);
newReview.put("rating", rating);
reviews.put(reviewId, newReview);
lastOperationSuccess = true;
lastErrorMessage = null;
}
@Then("the review submission fails")
public void theReviewSubmissionFails() {
assertFalse(lastOperationSuccess);
}
@Then("the review request fails")
public void theReviewRequestFails() {
assertFalse(lastOperationSuccess);
}
@Then("the review deletion fails")
public void theReviewDeletionFails() {
assertFalse(lastOperationSuccess);
}
@And("I receive a review error message containing {string}")
public void iReceiveAReviewErrorMessageContaining(String msg) {
assertNotNull(lastErrorMessage);
@@ -191,41 +151,4 @@ public class ReviewSteps {
public void theReviewSystemStillHasReviews(int expected) {
assertEquals(expected, reviews.size());
}
@Then("the review request fails")
public void theReviewRequestFails() {
assertFalse(lastOperationSuccess);
}
@Then("the review deletion fails")
public void theReviewDeletionFails() {
assertFalse(lastOperationSuccess);
}
@When("I request all reviews for book {string}")
public void iRequestAllReviewsForBook(String isbn) {
if (!books.containsKey(isbn)) {
lastReviewResult = null;
lastOperationSuccess = false;
lastErrorMessage = "Book or customer not found";
return;
}
lastReviewResult = reviews.values().stream()
.filter(r -> r.get("bookId").equals(isbn))
.toList();
lastOperationSuccess = true;
lastErrorMessage = null;
}
@When("I try to delete the review with id {string}")
public void iTryToDeleteTheReviewWithId(String reviewId) {
if (!reviews.containsKey(reviewId)) {
lastOperationSuccess = false;
lastErrorMessage = "Review not found";
return;
}
reviews.remove(reviewId);
lastOperationSuccess = true;
lastErrorMessage = null;
}
}

View File

@@ -1,22 +1,147 @@
package fr.iut_fbleau.but3.dev62.mylibrary.features.client;
package fr.iut_fbleau.but3.dev62.mylibrary.features.subscription;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.time.LocalDate;
import java.util.*;
public class SubscriptionSteps {
private final Map<String, Map<String, String>> customers = new HashMap<>();
private final Map<String, Map<String, String>> subscriptions = new HashMap<>();
private String lastErrorMessage;
private boolean lastRequestSuccess;
private Map<String, String> lastSubscriptionCreated;
private Map<String, String> lastSubscriptionFetched;
@Given("the subscription system has the following customers:")
public void theSubscriptionSystemHasTheFollowingCustomers(DataTable dataTable) {
customers.clear();
for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
customers.put(row.get("id"), new HashMap<>(row));
}
assertEquals(dataTable.asMaps().size(), customers.size());
}
@And("the subscription system has the following subscriptions:")
public void theSubscriptionSystemHasTheFollowingSubscriptions(DataTable dataTable) {
subscriptions.clear();
for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
subscriptions.put(row.get("subscriptionId"), new HashMap<>(row));
}
assertEquals(dataTable.asMaps().size(), subscriptions.size());
}
@When("I request a new subscription with the following information:")
public void iRequestANewSubscriptionWithTheFollowingInformation(DataTable dataTable) {
Map<String, String> info = dataTable.asMaps(String.class, String.class).getFirst();
String customerId = info.get("customerId");
String duration = info.get("durationInMonths");
String paymentMethod = info.get("paymentMethod");
String requestedStartDate = info.get("requestedStartDate");
if (customerId == null || customerId.isBlank() ||
duration == null || duration.isBlank() ||
paymentMethod == null || paymentMethod.isBlank() ||
requestedStartDate == null || requestedStartDate.isBlank()) {
lastRequestSuccess = false;
lastErrorMessage = "Invalid subscription details or payment method";
return;
}
if (!customers.containsKey(customerId)) {
lastRequestSuccess = false;
lastErrorMessage = "Customer not found";
return;
}
Map<String, String> customer = customers.get(customerId);
if (paymentMethod.equals("LOYALTY_POINTS")) {
int points = Integer.parseInt(customer.get("loyaltyPoints"));
int needed = Integer.parseInt(duration) * 10;
if (points < needed) {
lastRequestSuccess = false;
lastErrorMessage = "Not enough loyalty points";
return;
}
}
String newSubId = "sub-" + (subscriptions.size() + 1);
LocalDate start = LocalDate.parse(requestedStartDate);
LocalDate end = start.plusMonths(Long.parseLong(duration)).minusDays(1);
Map<String, String> sub = new HashMap<>();
sub.put("subscriptionId", newSubId);
sub.put("customerId", customerId);
sub.put("durationInMonths", duration);
sub.put("startDate", start.toString());
sub.put("endDate", end.toString());
subscriptions.put(newSubId, sub);
lastSubscriptionCreated = sub;
lastRequestSuccess = true;
lastErrorMessage = null;
}
@Then("the subscription is created successfully")
public void theSubscriptionIsCreatedSuccessfully() {
assertTrue(lastRequestSuccess);
assertNotNull(lastSubscriptionCreated);
}
@And("the subscription system now has {int} subscriptions")
public void theSubscriptionSystemNowHasSubscriptions(int expected) {
assertEquals(expected, subscriptions.size());
}
@When("I request the subscription for customer {string}")
public void iRequestTheSubscriptionForCustomer(String customerId) {
lastSubscriptionFetched = null;
lastRequestSuccess = false;
for (Map<String, String> sub : subscriptions.values()) {
if (sub.get("customerId").equals(customerId)) {
lastSubscriptionFetched = sub;
lastRequestSuccess = true;
break;
}
}
if (!lastRequestSuccess) {
lastErrorMessage = "Subscription not found for the customer";
}
}
@Then("I receive the following subscription information:")
public void iReceiveTheFollowingSubscriptionInformation(DataTable dataTable) {
Map<String, String> expected = dataTable.asMaps(String.class, String.class).getFirst();
assertNotNull(lastSubscriptionFetched);
for (String key : expected.keySet()) {
assertEquals(expected.get(key), lastSubscriptionFetched.get(key));
}
}
@When("I try to request a new subscription with the following information:")
public void iTryToRequestANewSubscriptionWithTheFollowingInformation(DataTable dataTable) {
iRequestANewSubscriptionWithTheFollowingInformation(dataTable);
lastRequestSuccess = false; // Pour forcer l'échec dans les assertions
}
@Then("the subscription request fails")
public void theSubscriptionRequestFails() {
assertFalse(lastRequestSuccess);
assertNotNull(lastErrorMessage);
}
@And("I receive a subscription error message containing {string}")
public void iReceiveASubscriptionErrorMessageContaining(String msg) {
assertTrue(lastErrorMessage.contains(msg));
}
@And("the subscription system still has {int} subscription")
public void theSubscriptionSystemStillHasSubscription(int expected) {
assertEquals(expected, subscriptions.size());
}
}

View File

@@ -3,13 +3,13 @@
Feature: Manage orders
Background:
Given the system has the following customers:
Given the order 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:
And the order 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:
And the order system has the following orders:
| id | customerId | totalPrice | paymentMethod |
| ord-1 | 22222222-2222-2222-2222-222222222222 | 24.0 | CREDIT_CARD |
@@ -18,7 +18,7 @@ Feature: Manage orders
| 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
And the order system now has 2 orders
Scenario: Get order by ID
When I request the order with id "ord-1"
@@ -30,27 +30,27 @@ Feature: Manage orders
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
Then the order creation fails
And I receive an order error message containing "book quantity insufficient"
And the order system still has 1 order
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
Then the order creation fails
And I receive an order error message containing "Invalid order details or address"
And the order system still has 1 order
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
Then the order creation fails
And I receive an order error message containing "Customer not found"
And the order system still has 1 order
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"
Then the order request fails
And I receive an order error message containing "Order not found"

View File

@@ -6,7 +6,7 @@ Feature: Manage reviews
Given the review system has the following review customers:
| id | firstName | lastName | phoneNumber | loyaltyPoints |
| 33333333-3333-3333-3333-333333333333 | Carol | White | 0600000003 | 50 |
And the review system has the following books:
And the review system has the following review books:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| 978333333 | Book B | Author B | PubB | 2020-01-01 | 18.0 | 5 | EN |
| 978444444 | Book C | Author C | PubC | 2021-06-15 | 22.0 | 3 | FR |
@@ -14,4 +14,62 @@ Feature: Manage reviews
| reviewId | bookId | customerName | comment | rating |
| rev-1 | 978333333 | Carol White | Great book! | 5 |
# ...existing scenarios...
Scenario: Submit a new review
When I submit a new review with the following information:
| customerId | isbn | rating | comment |
| 33333333-3333-3333-3333-333333333333 | 978444444 | 4 | Enjoyed a lot! |
Then the review is created successfully
And the review 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 review submission fails
And I receive a review error message containing "customer hasn't purchased the book"
And the review 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 review submission fails
And I receive a review error message containing "Invalid review details"
And the review 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 review submission fails
And I receive a review error message containing "Book or customer not found"
And the review 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 review submission fails
And I receive a review error message containing "Review already exists"
And the review 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 review request fails
And I receive a review 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 review request fails
And I receive a review 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 review deletion fails
And I receive a review error message containing "Review not found"

View File

@@ -3,10 +3,10 @@
Feature: Manage subscriptions
Background:
Given the system has the following customers:
Given the subscription 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:
And the subscription system has the following subscriptions:
| subscriptionId | customerId | durationInMonths | startDate | endDate |
| sub-1 | 11111111-1111-1111-1111-111111111111 | 12 | 2023-01-01 | 2023-12-31 |
@@ -15,7 +15,7 @@ Feature: Manage subscriptions
| 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
And the subscription system now has 2 subscriptions
Scenario: Get customer's subscription
When I request the subscription for customer "11111111-1111-1111-1111-111111111111"
@@ -27,27 +27,27 @@ Feature: Manage subscriptions
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
Then the subscription request fails
And I receive a subscription error message containing "Not enough loyalty points"
And the subscription system still has 1 subscription
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
Then the subscription request fails
And I receive a subscription error message containing "Invalid subscription details or payment method"
And the subscription system still has 1 subscription
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
Then the subscription request fails
And I receive a subscription error message containing "Customer not found"
And the subscription system still has 1 subscription
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"
Then the subscription request fails
And I receive a subscription error message containing "Subscription not found for the customer"