Compare commits
	
		
			15 Commits
		
	
	
		
			main
			...
			b8091da304
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					b8091da304 | ||
| 
						 | 
					52994a20a3 | ||
| 
						 | 
					c20be4d5f6 | ||
| 459d03b36b | |||
| d18a9074a3 | |||
| cdf4c046bc | |||
| cc4dfa140a | |||
| 
						 | 
					1b70a8d123 | ||
| 
						 | 
					bf0f309963 | ||
| a27dba9ad2 | |||
| 76f2145629 | |||
| 91b3cfe76a | |||
| 
						 | 
					c7230c889e | ||
| 0b1d59390f | |||
| 80d857747c | 
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -8,6 +8,7 @@ target/
 | 
				
			|||||||
.idea/jarRepositories.xml
 | 
					.idea/jarRepositories.xml
 | 
				
			||||||
.idea/compiler.xml
 | 
					.idea/compiler.xml
 | 
				
			||||||
.idea/libraries/
 | 
					.idea/libraries/
 | 
				
			||||||
 | 
					.idea/misc.xml
 | 
				
			||||||
*.iws
 | 
					*.iws
 | 
				
			||||||
*.iml
 | 
					*.iml
 | 
				
			||||||
*.ipr
 | 
					*.ipr
 | 
				
			||||||
@@ -35,4 +36,4 @@ build/
 | 
				
			|||||||
.vscode/
 | 
					.vscode/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Mac OS ###
 | 
					### Mac OS ###
 | 
				
			||||||
.DS_Store
 | 
					.DS_Store
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								.idea/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								.idea/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					# Default ignored files
 | 
				
			||||||
 | 
					/shelf/
 | 
				
			||||||
 | 
					/workspace.xml
 | 
				
			||||||
 | 
					# Environment-dependent path to Maven home directory
 | 
				
			||||||
 | 
					/mavenHomeManager.xml
 | 
				
			||||||
							
								
								
									
										7
									
								
								.idea/encodings.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.idea/encodings.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project version="4">
 | 
				
			||||||
 | 
					  <component name="Encoding">
 | 
				
			||||||
 | 
					    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
 | 
				
			||||||
 | 
					    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
 | 
				
			||||||
 | 
					  </component>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
							
								
								
									
										6
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/vcs.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project version="4">
 | 
				
			||||||
 | 
					  <component name="VcsDirectoryMappings">
 | 
				
			||||||
 | 
					    <mapping directory="" vcs="Git" />
 | 
				
			||||||
 | 
					  </component>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Book {
 | 
				
			||||||
 | 
					    private String isbn;
 | 
				
			||||||
 | 
					    private String title;
 | 
				
			||||||
 | 
					    private String author;
 | 
				
			||||||
 | 
					    private String publisher;
 | 
				
			||||||
 | 
					    private String publicationDate;
 | 
				
			||||||
 | 
					    private String price;
 | 
				
			||||||
 | 
					    private String quantity;
 | 
				
			||||||
 | 
					    private String language;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Book(String isbn, String title, String author, String publisher,
 | 
				
			||||||
 | 
					                String publicationDate, String price, String quantity, String language) {
 | 
				
			||||||
 | 
					        this.isbn = isbn;
 | 
				
			||||||
 | 
					        this.title = title;
 | 
				
			||||||
 | 
					        this.author = author;
 | 
				
			||||||
 | 
					        this.publisher = publisher;
 | 
				
			||||||
 | 
					        this.publicationDate = publicationDate;
 | 
				
			||||||
 | 
					        this.price = price;
 | 
				
			||||||
 | 
					        this.quantity = quantity;
 | 
				
			||||||
 | 
					        this.language = language;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Getters (setters optionnels si besoin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getIsbn() {
 | 
				
			||||||
 | 
					        return isbn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public String getTitle() {
 | 
				
			||||||
 | 
					        return title;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public String getAuthor() {
 | 
				
			||||||
 | 
					        return author;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public String getPublisher() {
 | 
				
			||||||
 | 
					        return publisher;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public String getPublicationDate() {
 | 
				
			||||||
 | 
					        return publicationDate;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public String getPrice() {
 | 
				
			||||||
 | 
					        return price;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public String getQuantity() {
 | 
				
			||||||
 | 
					        return quantity;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public String getLanguage() {
 | 
				
			||||||
 | 
					        return language;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,57 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import fr.iut_fbleau.but3.dev62.mylibrary.book.exception.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class BookManagement {
 | 
				
			||||||
 | 
					    private final Map<String, Book> books = new LinkedHashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean registerBook(Book book) throws InvalidBookDataException, DuplicateBookException {
 | 
				
			||||||
 | 
					        if (!isValid(book)) {
 | 
				
			||||||
 | 
					            throw new InvalidBookDataException("Invalid book data provided");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (books.containsKey(book.getIsbn())) {
 | 
				
			||||||
 | 
					            throw new DuplicateBookException("Conflict with existing book in database");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        books.put(book.getIsbn(), book);
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public List<Book> getAllBooks() {
 | 
				
			||||||
 | 
					        return new ArrayList<>(books.values());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Book getBookByIsbn(String isbn) throws BookNotFoundException {
 | 
				
			||||||
 | 
					        if (!books.containsKey(isbn)) {
 | 
				
			||||||
 | 
					            throw new BookNotFoundException("Book not found");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return books.get(isbn);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public List<Book> getBooksByTitle(String title) {
 | 
				
			||||||
 | 
					        return books.values().stream()
 | 
				
			||||||
 | 
					                .filter(book -> book.getTitle().equalsIgnoreCase(title))
 | 
				
			||||||
 | 
					                .toList();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getBookCount() {
 | 
				
			||||||
 | 
					        return books.size();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean isValid(Book book) {
 | 
				
			||||||
 | 
					        return book != null &&
 | 
				
			||||||
 | 
					                notEmpty(book.getIsbn()) &&
 | 
				
			||||||
 | 
					                notEmpty(book.getTitle()) &&
 | 
				
			||||||
 | 
					                notEmpty(book.getAuthor()) &&
 | 
				
			||||||
 | 
					                notEmpty(book.getPublisher()) &&
 | 
				
			||||||
 | 
					                notEmpty(book.getPublicationDate()) &&
 | 
				
			||||||
 | 
					                notEmpty(book.getPrice()) &&
 | 
				
			||||||
 | 
					                notEmpty(book.getQuantity()) &&
 | 
				
			||||||
 | 
					                notEmpty(book.getLanguage());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean notEmpty(String value) {
 | 
				
			||||||
 | 
					        return value != null && !value.isBlank();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book.exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class BookNotFoundException extends Exception {
 | 
				
			||||||
 | 
					    public BookNotFoundException(String message) {
 | 
				
			||||||
 | 
					        super(message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book.exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class DuplicateBookException extends Exception {
 | 
				
			||||||
 | 
					    public DuplicateBookException(String message) {
 | 
				
			||||||
 | 
					        super(message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book.exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class InvalidBookDataException extends Exception {
 | 
				
			||||||
 | 
					    public InvalidBookDataException(String message) {
 | 
				
			||||||
 | 
					        super(message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book.error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.jupiter.api.*;
 | 
				
			||||||
 | 
					import static org.junit.jupiter.api.Assertions.*;
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@DisplayName("Book error and failure scenarios")
 | 
				
			||||||
 | 
					public class bookErrorTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String lastErrorMessage;
 | 
				
			||||||
 | 
					    private boolean lastOperationSuccess;
 | 
				
			||||||
 | 
					    private List<Map<String, String>> lastBookResult;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Registration fails when data is invalid")
 | 
				
			||||||
 | 
					    void testRegistrationFails() {
 | 
				
			||||||
 | 
					        lastOperationSuccess = false;
 | 
				
			||||||
 | 
					        assertFalse(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Error message contains expected substring")
 | 
				
			||||||
 | 
					    void testErrorMessageContains() {
 | 
				
			||||||
 | 
					        lastErrorMessage = "Conflict with existing book in database";
 | 
				
			||||||
 | 
					        assertNotNull(lastErrorMessage);
 | 
				
			||||||
 | 
					        assertTrue(lastErrorMessage.contains("Conflict"));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Receiving an empty list of books")
 | 
				
			||||||
 | 
					    void testEmptyBookList() {
 | 
				
			||||||
 | 
					        lastBookResult = new ArrayList<>();
 | 
				
			||||||
 | 
					        assertNotNull(lastBookResult);
 | 
				
			||||||
 | 
					        assertTrue(lastBookResult.isEmpty());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Request fails")
 | 
				
			||||||
 | 
					    void testRequestFails() {
 | 
				
			||||||
 | 
					        lastOperationSuccess = false;
 | 
				
			||||||
 | 
					        assertFalse(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,145 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book.function;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static org.junit.jupiter.api.Assertions.*;
 | 
				
			||||||
 | 
					import io.cucumber.datatable.DataTable;
 | 
				
			||||||
 | 
					import org.junit.jupiter.api.*;
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@DisplayName("Book retrieval scenarios and data registration")
 | 
				
			||||||
 | 
					public class bookFunctionTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Map<String, Map<String, String>> books;
 | 
				
			||||||
 | 
					    private List<Map<String, String>> lastBookResult;
 | 
				
			||||||
 | 
					    private Map<String, String> lastSingleBookResult;
 | 
				
			||||||
 | 
					    private boolean lastOperationSuccess;
 | 
				
			||||||
 | 
					    private String lastErrorMessage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @BeforeEach
 | 
				
			||||||
 | 
					    void setUp() {
 | 
				
			||||||
 | 
					        books = new HashMap<>();
 | 
				
			||||||
 | 
					        lastBookResult = new ArrayList<>();
 | 
				
			||||||
 | 
					        lastSingleBookResult = null;
 | 
				
			||||||
 | 
					        lastOperationSuccess = false;
 | 
				
			||||||
 | 
					        lastErrorMessage = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Register a new book with valid data")
 | 
				
			||||||
 | 
					    void testRegisterNewBook() {
 | 
				
			||||||
 | 
					        DataTable dataTable = DataTable.create(
 | 
				
			||||||
 | 
					                List.of(
 | 
				
			||||||
 | 
					                        List.of("isbn", "title", "author", "publisher", "publicationDate", "price", "quantity", "language"),
 | 
				
			||||||
 | 
					                        List.of("999", "La vie de Bob", "Boby Bob", "Bob", "2025-01-01", "29.99", "10", "FR")
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        iRegisterANewBookWithTheFollowingInformation(dataTable);
 | 
				
			||||||
 | 
					        assertTrue(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void iRegisterANewBookWithTheFollowingInformation(DataTable dataTable) {
 | 
				
			||||||
 | 
					        Map<String, String> newBook = dataTable.asMaps(String.class, String.class).get(0);
 | 
				
			||||||
 | 
					        String isbn = newBook.get("isbn");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (isbn == null || isbn.isBlank()
 | 
				
			||||||
 | 
					                || newBook.get("title") == null || newBook.get("title").isBlank()
 | 
				
			||||||
 | 
					                || newBook.get("author") == null || newBook.get("author").isBlank()
 | 
				
			||||||
 | 
					                || newBook.get("publisher") == null || newBook.get("publisher").isBlank()
 | 
				
			||||||
 | 
					                || newBook.get("publicationDate") == null || newBook.get("publicationDate").isBlank()
 | 
				
			||||||
 | 
					                || newBook.get("price") == null || newBook.get("price").isBlank()
 | 
				
			||||||
 | 
					                || newBook.get("quantity") == null || newBook.get("quantity").isBlank()
 | 
				
			||||||
 | 
					                || newBook.get("language") == null || newBook.get("language").isBlank()) {
 | 
				
			||||||
 | 
					            lastOperationSuccess = false;
 | 
				
			||||||
 | 
					            lastErrorMessage = "Invalid book data provided";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (books.containsKey(isbn)) {
 | 
				
			||||||
 | 
					            lastOperationSuccess = false;
 | 
				
			||||||
 | 
					            lastErrorMessage = "Conflict with existing book in database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        books.put(isbn, new HashMap<>(newBook));
 | 
				
			||||||
 | 
					        lastOperationSuccess = true;
 | 
				
			||||||
 | 
					        lastErrorMessage = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Request all books")
 | 
				
			||||||
 | 
					    void testRequestAllBooks() {
 | 
				
			||||||
 | 
					        books.put("1", Map.of("title", "Livre A"));
 | 
				
			||||||
 | 
					        books.put("2", Map.of("title", "Livre B"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        iRequestAllBooks();
 | 
				
			||||||
 | 
					        assertEquals(2, lastBookResult.size());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void iRequestAllBooks() {
 | 
				
			||||||
 | 
					        lastBookResult = new ArrayList<>(books.values());
 | 
				
			||||||
 | 
					        lastOperationSuccess = true;
 | 
				
			||||||
 | 
					        lastErrorMessage = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Request single book by ID")
 | 
				
			||||||
 | 
					    void testRequestBookById() {
 | 
				
			||||||
 | 
					        books.put("123", Map.of("isbn", "123", "title", "blabla"));
 | 
				
			||||||
 | 
					        iRequestTheBookWithId("123");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        assertNotNull(lastSingleBookResult);
 | 
				
			||||||
 | 
					        assertEquals("blabla", lastSingleBookResult.get("title"));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void iRequestTheBookWithId(String isbn) {
 | 
				
			||||||
 | 
					        if (!books.containsKey(isbn)) {
 | 
				
			||||||
 | 
					            lastSingleBookResult = null;
 | 
				
			||||||
 | 
					            lastOperationSuccess = false;
 | 
				
			||||||
 | 
					            lastErrorMessage = "Book not found";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        lastSingleBookResult = books.get(isbn);
 | 
				
			||||||
 | 
					        lastOperationSuccess = true;
 | 
				
			||||||
 | 
					        lastErrorMessage = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Attempt to register a book that should fail")
 | 
				
			||||||
 | 
					    void testRegisterBookWithExpectedFailure() {
 | 
				
			||||||
 | 
					        DataTable dataTable = DataTable.create(
 | 
				
			||||||
 | 
					                List.of(
 | 
				
			||||||
 | 
					                        List.of("isbn", "title", "author", "publisher", "publicationDate", "price", "quantity", "language"),
 | 
				
			||||||
 | 
					                        List.of("666", "La vie de Boby", "Boby Bob", "bob", "2025-01-01", "25.00", "10", "FR")
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        iTryToRegisterANewBookWithTheFollowingInformation(dataTable);
 | 
				
			||||||
 | 
					        assertFalse(lastOperationSuccess);
 | 
				
			||||||
 | 
					        assertNotNull(lastErrorMessage);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void iTryToRegisterANewBookWithTheFollowingInformation(DataTable dataTable) {
 | 
				
			||||||
 | 
					        iRegisterANewBookWithTheFollowingInformation(dataTable);
 | 
				
			||||||
 | 
					        if (lastOperationSuccess) {
 | 
				
			||||||
 | 
					            lastOperationSuccess = false;
 | 
				
			||||||
 | 
					            lastErrorMessage = "Expected failure but succeeded";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Request all books with specific title")
 | 
				
			||||||
 | 
					    void testRequestBooksByTitle() {
 | 
				
			||||||
 | 
					        books.put("1", Map.of("title", "Wouah"));
 | 
				
			||||||
 | 
					        books.put("2", Map.of("title", "Troop"));
 | 
				
			||||||
 | 
					        books.put("3", Map.of("title", "Bien"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        iRequestAllBooksWithTitle("Bien");
 | 
				
			||||||
 | 
					        assertEquals(2, lastBookResult.size());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void iRequestAllBooksWithTitle(String titleFilter) {
 | 
				
			||||||
 | 
					        lastBookResult = books.values().stream()
 | 
				
			||||||
 | 
					                .filter(book -> book.get("title").equalsIgnoreCase(titleFilter))
 | 
				
			||||||
 | 
					                .toList();
 | 
				
			||||||
 | 
					        lastOperationSuccess = true;
 | 
				
			||||||
 | 
					        lastErrorMessage = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,81 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.book.result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.jupiter.api.*;
 | 
				
			||||||
 | 
					import static org.junit.jupiter.api.Assertions.*;
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@DisplayName("Book result success scenarios")
 | 
				
			||||||
 | 
					public class bookResultTest {
 | 
				
			||||||
 | 
					    private Map<String, String> lastSingleBookResult;
 | 
				
			||||||
 | 
					    private Map<String, Map<String, String>> books;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @BeforeEach
 | 
				
			||||||
 | 
					    void setUp() {
 | 
				
			||||||
 | 
					        books = new HashMap<>();
 | 
				
			||||||
 | 
					        books.put("123", Map.of("titre", "Livre A"));
 | 
				
			||||||
 | 
					        books.put("456", Map.of("title", "Livre B"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        lastSingleBookResult = Map.of(
 | 
				
			||||||
 | 
					                "isbn", "888",
 | 
				
			||||||
 | 
					                "title", "La vie de Bob",
 | 
				
			||||||
 | 
					                "author", "Boby Bob",
 | 
				
			||||||
 | 
					                "publisher", "Bob",
 | 
				
			||||||
 | 
					                "publicationDate", "2025-01-01",
 | 
				
			||||||
 | 
					                "price", "29.99",
 | 
				
			||||||
 | 
					                "quantity", "10",
 | 
				
			||||||
 | 
					                "language", "Fr"
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Book is successfully registered")
 | 
				
			||||||
 | 
					    void testBookRegistrationSuccess() {
 | 
				
			||||||
 | 
					        boolean lastOperationSuccess = true;
 | 
				
			||||||
 | 
					        assertTrue(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("Receive detailed information of a single book")
 | 
				
			||||||
 | 
					    void testReceiveSingleBookInformation() {
 | 
				
			||||||
 | 
					        lastSingleBookResult = Map.of(
 | 
				
			||||||
 | 
					                "isbn", "777",
 | 
				
			||||||
 | 
					                "title", "La vie de Bob",
 | 
				
			||||||
 | 
					                "author", "Boby Bob",
 | 
				
			||||||
 | 
					                "publisher", "Bob",
 | 
				
			||||||
 | 
					                "publicationDate", "2025-01-01",
 | 
				
			||||||
 | 
					                "price", "29.99",
 | 
				
			||||||
 | 
					                "quantity", "10",
 | 
				
			||||||
 | 
					                "language", "Fr"
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<Map<String, String>> expectedList = List.of(Map.of(
 | 
				
			||||||
 | 
					                "isbn", "001",
 | 
				
			||||||
 | 
					                "title", "La vie de mary",
 | 
				
			||||||
 | 
					                "author", "Mary Mard",
 | 
				
			||||||
 | 
					                "publisher", "Mary",
 | 
				
			||||||
 | 
					                "publicationDate", "2025-02-02",
 | 
				
			||||||
 | 
					                "price", "29.99",
 | 
				
			||||||
 | 
					                "quantity", "10",
 | 
				
			||||||
 | 
					                "language", "Fr"
 | 
				
			||||||
 | 
					        ));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Map<String, String> expectedBook = expectedList.get(0);
 | 
				
			||||||
 | 
					        assertNotNull(lastSingleBookResult);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (String key : expectedBook.keySet()) {
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get(key), lastSingleBookResult.get(key));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("System has expected number of books after registration")
 | 
				
			||||||
 | 
					    void testSystemHasBooks() {
 | 
				
			||||||
 | 
					        assertEquals(2, books.size());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    @DisplayName("System still has expected number of books")
 | 
				
			||||||
 | 
					    void testSystemStillHasBooks() {
 | 
				
			||||||
 | 
					        assertEquals(2, books.size());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,161 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.features.book;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import fr.iut_fbleau.but3.dev62.mylibrary.book.*;
 | 
				
			||||||
 | 
					import fr.iut_fbleau.but3.dev62.mylibrary.book.exception.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static org.junit.jupiter.api.Assertions.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import io.cucumber.datatable.DataTable;
 | 
				
			||||||
 | 
					import io.cucumber.java.en.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class BookSteps {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final BookManagement bookManagement = new BookManagement();
 | 
				
			||||||
 | 
					    private List<Book> lastBookResult;
 | 
				
			||||||
 | 
					    private Book lastSingleBookResult;
 | 
				
			||||||
 | 
					    private String lastErrorMessage;
 | 
				
			||||||
 | 
					    private boolean lastOperationSuccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ----------------------------Background--------------------------------
 | 
				
			||||||
 | 
					    @Given("the system has the following books:")
 | 
				
			||||||
 | 
					    public void theSystemHasTheFollowingBooks(DataTable dataTable) {
 | 
				
			||||||
 | 
					        for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                Book book = new Book(
 | 
				
			||||||
 | 
					                        row.get("isbn"),
 | 
				
			||||||
 | 
					                        row.get("title"),
 | 
				
			||||||
 | 
					                        row.get("author"),
 | 
				
			||||||
 | 
					                        row.get("publisher"),
 | 
				
			||||||
 | 
					                        row.get("publicationDate"),
 | 
				
			||||||
 | 
					                        row.get("price"),
 | 
				
			||||||
 | 
					                        row.get("quantity"),
 | 
				
			||||||
 | 
					                        row.get("language")
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					                bookManagement.registerBook(book);
 | 
				
			||||||
 | 
					            } catch (Exception ignored) {}
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ----------------------------Scénario 1 et 4 (succès ou échec)---------------------------------
 | 
				
			||||||
 | 
					    @When("I register a new book with the following information:")
 | 
				
			||||||
 | 
					    @When("I try to register a new book with the following information:")
 | 
				
			||||||
 | 
					    public void iRegisterANewBookWithTheFollowingInformation(DataTable dataTable) {
 | 
				
			||||||
 | 
					        Map<String, String> row = dataTable.asMaps(String.class, String.class).get(0);
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            Book book = new Book(
 | 
				
			||||||
 | 
					                    row.get("isbn"),
 | 
				
			||||||
 | 
					                    row.get("title"),
 | 
				
			||||||
 | 
					                    row.get("author"),
 | 
				
			||||||
 | 
					                    row.get("publisher"),
 | 
				
			||||||
 | 
					                    row.get("publicationDate"),
 | 
				
			||||||
 | 
					                    row.get("price"),
 | 
				
			||||||
 | 
					                    row.get("quantity"),
 | 
				
			||||||
 | 
					                    row.get("language")
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            bookManagement.registerBook(book);
 | 
				
			||||||
 | 
					            lastOperationSuccess = true;
 | 
				
			||||||
 | 
					            lastErrorMessage = null;
 | 
				
			||||||
 | 
					        } catch (InvalidBookDataException | DuplicateBookException e) {
 | 
				
			||||||
 | 
					            lastOperationSuccess = false;
 | 
				
			||||||
 | 
					            lastErrorMessage = e.getMessage();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Then("the book is successfully registered")
 | 
				
			||||||
 | 
					    public void theBookIsSuccessfullyRegistered() {
 | 
				
			||||||
 | 
					        assertTrue(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Then("the registration fails")
 | 
				
			||||||
 | 
					    public void theRegistrationFails() {
 | 
				
			||||||
 | 
					        assertFalse(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @And("I receive an error message containing {string}")
 | 
				
			||||||
 | 
					    public void iReceiveAnErrorMessageContaining(String msg) {
 | 
				
			||||||
 | 
					        assertNotNull(lastErrorMessage);
 | 
				
			||||||
 | 
					        assertTrue(lastErrorMessage.contains(msg));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @And("the system now has {int} books")
 | 
				
			||||||
 | 
					    @And("the system still has {int} books")
 | 
				
			||||||
 | 
					    public void theSystemHasBooks(int expectedCount) {
 | 
				
			||||||
 | 
					        assertEquals(expectedCount, bookManagement.getBookCount());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ----------------------------Scénario 2---------------------------------
 | 
				
			||||||
 | 
					    @When("I request all books")
 | 
				
			||||||
 | 
					    public void iRequestAllBooks() {
 | 
				
			||||||
 | 
					        lastBookResult = bookManagement.getAllBooks();
 | 
				
			||||||
 | 
					        lastOperationSuccess = true;
 | 
				
			||||||
 | 
					        lastErrorMessage = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Then("I receive the following books:")
 | 
				
			||||||
 | 
					    public void iReceiveTheFollowingBooks(DataTable expectedTable) {
 | 
				
			||||||
 | 
					        List<Map<String, String>> expected = expectedTable.asMaps(String.class, String.class);
 | 
				
			||||||
 | 
					        assertNotNull(lastBookResult);
 | 
				
			||||||
 | 
					        assertEquals(expected.size(), lastBookResult.size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < expected.size(); i++) {
 | 
				
			||||||
 | 
					            Book actual = lastBookResult.get(i);
 | 
				
			||||||
 | 
					            Map<String, String> expectedBook = expected.get(i);
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("isbn"), actual.getIsbn());
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("title"), actual.getTitle());
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("author"), actual.getAuthor());
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("publisher"), actual.getPublisher());
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("publicationDate"), actual.getPublicationDate());
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("price"), actual.getPrice());
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("quantity"), actual.getQuantity());
 | 
				
			||||||
 | 
					            assertEquals(expectedBook.get("language"), actual.getLanguage());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ----------------------------Scénario 3---------------------------------
 | 
				
			||||||
 | 
					    @When("I request the book with id {string}")
 | 
				
			||||||
 | 
					    public void iRequestTheBookWithId(String isbn) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            lastSingleBookResult = bookManagement.getBookByIsbn(isbn);
 | 
				
			||||||
 | 
					            lastOperationSuccess = true;
 | 
				
			||||||
 | 
					            lastErrorMessage = null;
 | 
				
			||||||
 | 
					        } catch (BookNotFoundException e) {
 | 
				
			||||||
 | 
					            lastOperationSuccess = false;
 | 
				
			||||||
 | 
					            lastErrorMessage = e.getMessage();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Then("I receive the following book information:")
 | 
				
			||||||
 | 
					    public void iReceiveTheFollowingBookInformation(DataTable expectedTable) {
 | 
				
			||||||
 | 
					        Map<String, String> expectedBook = expectedTable.asMaps(String.class, String.class).get(0);
 | 
				
			||||||
 | 
					        assertNotNull(lastSingleBookResult);
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("isbn"), lastSingleBookResult.getIsbn());
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("title"), lastSingleBookResult.getTitle());
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("author"), lastSingleBookResult.getAuthor());
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("publisher"), lastSingleBookResult.getPublisher());
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("publicationDate"), lastSingleBookResult.getPublicationDate());
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("price"), lastSingleBookResult.getPrice());
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("quantity"), lastSingleBookResult.getQuantity());
 | 
				
			||||||
 | 
					        assertEquals(expectedBook.get("language"), lastSingleBookResult.getLanguage());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // ----------------------------Scénario 6---------------------------------
 | 
				
			||||||
 | 
					    @When("I request all books with title {string}")
 | 
				
			||||||
 | 
					    public void iRequestAllBooksWithTitle(String titleFilter) {
 | 
				
			||||||
 | 
					        lastBookResult = bookManagement.getBooksByTitle(titleFilter);
 | 
				
			||||||
 | 
					        lastOperationSuccess = true;
 | 
				
			||||||
 | 
					        lastErrorMessage = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Then("I receive an empty list of books")
 | 
				
			||||||
 | 
					    public void iReceiveAnEmptyListOfBooks() {
 | 
				
			||||||
 | 
					        assertNotNull(lastBookResult);
 | 
				
			||||||
 | 
					        assertTrue(lastBookResult.isEmpty());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @When("the request fails")
 | 
				
			||||||
 | 
					    public void theRequestFails() {
 | 
				
			||||||
 | 
					        assertFalse(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -14,6 +14,8 @@ import fr.iut_fbleau.but3.dev62.mylibrary.customer.exception.IllegalCustomerPoin
 | 
				
			|||||||
import fr.iut_fbleau.but3.dev62.mylibrary.customer.exception.NotValidCustomerException;
 | 
					import fr.iut_fbleau.but3.dev62.mylibrary.customer.exception.NotValidCustomerException;
 | 
				
			||||||
import fr.iut_fbleau.but3.dev62.mylibrary.customer.repository.CustomerRepository;
 | 
					import fr.iut_fbleau.but3.dev62.mylibrary.customer.repository.CustomerRepository;
 | 
				
			||||||
import fr.iut_fbleau.but3.dev62.mylibrary.customer.usecase.CustomerUseCase;
 | 
					import fr.iut_fbleau.but3.dev62.mylibrary.customer.usecase.CustomerUseCase;
 | 
				
			||||||
 | 
					import io.cucumber.datatable.DataTable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import io.cucumber.datatable.DataTable;
 | 
					import io.cucumber.datatable.DataTable;
 | 
				
			||||||
import io.cucumber.java.en.And;
 | 
					import io.cucumber.java.en.And;
 | 
				
			||||||
import io.cucumber.java.en.Given;
 | 
					import io.cucumber.java.en.Given;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.features.client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class OrderSteps {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,231 @@
 | 
				
			|||||||
 | 
					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 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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Given("the review system has the following review customers:")
 | 
				
			||||||
 | 
					    public void theReviewSystemHasTheFollowingReviewCustomers(DataTable dataTable) {
 | 
				
			||||||
 | 
					        customers.clear();
 | 
				
			||||||
 | 
					        for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
 | 
				
			||||||
 | 
					            customers.put(row.get("id"), row);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Given("the review system has the following books:")
 | 
				
			||||||
 | 
					    public void theReviewSystemHasTheFollowingBooks(DataTable dataTable) {
 | 
				
			||||||
 | 
					        books.clear();
 | 
				
			||||||
 | 
					        for (Map<String, String> row : dataTable.asMaps(String.class, String.class)) {
 | 
				
			||||||
 | 
					            books.put(row.get("isbn"), row);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Given("the review system has the following reviews:")
 | 
				
			||||||
 | 
					    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
 | 
				
			||||||
 | 
					        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 is created successfully")
 | 
				
			||||||
 | 
					    public void theReviewIsCreatedSuccessfully() {
 | 
				
			||||||
 | 
					        assertTrue(lastOperationSuccess);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Then("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));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @And("I receive a review error message containing {string}")
 | 
				
			||||||
 | 
					    public void iReceiveAReviewErrorMessageContaining(String msg) {
 | 
				
			||||||
 | 
					        assertNotNull(lastErrorMessage);
 | 
				
			||||||
 | 
					        assertTrue(lastErrorMessage.contains(msg));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @And("the review system still has {int} review")
 | 
				
			||||||
 | 
					    public void theReviewSystemStillHasReview(int expected) {
 | 
				
			||||||
 | 
					        assertEquals(expected, reviews.size());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @And("the review system still has {int} reviews")
 | 
				
			||||||
 | 
					    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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					package fr.iut_fbleau.but3.dev62.mylibrary.features.client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SubscriptionSteps {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										63
									
								
								src/test/resources/features/book.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/test/resources/features/book.feature
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
				
			|||||||
 | 
					# language: en
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Feature: Manage books
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 # ----------------------------Background---------------------------------
 | 
				
			||||||
 | 
					  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       |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 # ----------------------------Scénario 1---------------------------------
 | 
				
			||||||
 | 
					  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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 # ----------------------------Scénario 2---------------------------------
 | 
				
			||||||
 | 
					  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       |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 # ----------------------------Scénario 3---------------------------------
 | 
				
			||||||
 | 
					  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       |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 # ----------------------------Scénario 4---------------------------------
 | 
				
			||||||
 | 
					  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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 # ----------------------------Scénario 5---------------------------------
 | 
				
			||||||
 | 
					  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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 # ----------------------------Scénario 6---------------------------------
 | 
				
			||||||
 | 
					  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"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ----------------------------Scénario 7---------------------------------
 | 
				
			||||||
 | 
					  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
 | 
				
			||||||
							
								
								
									
										56
									
								
								src/test/resources/features/order.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/test/resources/features/order.feature
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
				
			|||||||
 | 
					# language: en
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Feature: Manage orders
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Background:
 | 
				
			||||||
 | 
					    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: 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    |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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: 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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: 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"
 | 
				
			||||||
							
								
								
									
										17
									
								
								src/test/resources/features/review.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/test/resources/features/review.feature
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					# language: en
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Feature: Manage reviews
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Background:
 | 
				
			||||||
 | 
					    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:
 | 
				
			||||||
 | 
					      | 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       |
 | 
				
			||||||
 | 
					    And the review system has the following reviews:
 | 
				
			||||||
 | 
					      | reviewId                               | bookId    | customerName | comment      | rating |
 | 
				
			||||||
 | 
					      | rev-1                                  | 978333333 | Carol White  | Great book!  | 5      |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # ...existing scenarios...
 | 
				
			||||||
							
								
								
									
										53
									
								
								src/test/resources/features/subscription.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/test/resources/features/subscription.feature
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					# language: en
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Feature: Manage subscriptions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Background:
 | 
				
			||||||
 | 
					    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: 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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: 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: 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: 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: 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"
 | 
				
			||||||
		Reference in New Issue
	
	Block a user