forked from pierront/mylibrary-template
book respect convention de nomage
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
package fr.iut_fbleau.but3.dev62.mylibrary.book;
|
package fr.iut_fbleau.but3.dev62.mylibrary.book;
|
||||||
|
|
||||||
public class book {
|
public class Book {
|
||||||
private String isbn;
|
private String isbn;
|
||||||
private String title;
|
private String title;
|
||||||
private String author;
|
private String author;
|
||||||
@@ -10,7 +10,7 @@ public class book {
|
|||||||
private String quantity;
|
private String quantity;
|
||||||
private String language;
|
private String language;
|
||||||
|
|
||||||
public book(String isbn, String title, String author, String publisher,
|
public Book(String isbn, String title, String author, String publisher,
|
||||||
String publicationDate, String price, String quantity, String language) {
|
String publicationDate, String price, String quantity, String language) {
|
||||||
this.isbn = isbn;
|
this.isbn = isbn;
|
||||||
this.title = title;
|
this.title = title;
|
@@ -1,10 +1,10 @@
|
|||||||
package fr.iut_fbleau.but3.dev62.mylibrary.book;
|
package fr.iut_fbleau.but3.dev62.mylibrary.book;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class bookManagement {
|
public class BookManagement {
|
||||||
private final Map<String, book> books = new LinkedHashMap<>();
|
private final Map<String, Book> books = new LinkedHashMap<>();
|
||||||
|
|
||||||
public boolean registerBook(book book) {
|
public boolean registerBook(Book book) {
|
||||||
if (!isValid(book)) {
|
if (!isValid(book)) {
|
||||||
throw new IllegalArgumentException("Invalid book data provided");
|
throw new IllegalArgumentException("Invalid book data provided");
|
||||||
}
|
}
|
||||||
@@ -15,20 +15,20 @@ public class bookManagement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<book> getAllBooks() {
|
public List<Book> getAllBooks() {
|
||||||
return new ArrayList<>(books.values());
|
return new ArrayList<>(books.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public book getBookByIsbn(String isbn) {
|
public Book getBookByIsbn(String isbn) {
|
||||||
if (!books.containsKey(isbn)) {
|
if (!books.containsKey(isbn)) {
|
||||||
throw new NoSuchElementException("Book not found");
|
throw new NoSuchElementException("Book not found");
|
||||||
}
|
}
|
||||||
return books.get(isbn);
|
return books.get(isbn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<book> getBooksByTitle(String title) {
|
public List<Book> getBooksByTitle(String title) {
|
||||||
return books.values().stream()
|
return books.values().stream()
|
||||||
.filter(book -> book.getTitle().equalsIgnoreCase(title))
|
.filter(Book -> Book.getTitle().equalsIgnoreCase(title))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public class bookManagement {
|
|||||||
return books.size();
|
return books.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValid(book book) {
|
private boolean isValid(Book book) {
|
||||||
return book != null &&
|
return book != null &&
|
||||||
notEmpty(book.getIsbn()) &&
|
notEmpty(book.getIsbn()) &&
|
||||||
notEmpty(book.getTitle()) &&
|
notEmpty(book.getTitle()) &&
|
@@ -1,11 +1,11 @@
|
|||||||
package fr.iut_fbleau.but3.dev62.mylibrary.book.bookError;
|
package fr.iut_fbleau.but3.dev62.mylibrary.book.error;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@DisplayName("Book error and failure scenarios")
|
@DisplayName("Book error and failure scenarios")
|
||||||
public class error {
|
public class bookErrorTest {
|
||||||
|
|
||||||
private String lastErrorMessage;
|
private String lastErrorMessage;
|
||||||
private boolean lastOperationSuccess;
|
private boolean lastOperationSuccess;
|
@@ -1,4 +1,8 @@
|
|||||||
package fr.iut_fbleau.but3.dev62.mylibrary.features.book;
|
package fr.iut_fbleau.but3.dev62.mylibrary.features.book;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.book.error.bookErrorTest;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.book.function.bookFunctionTest;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.book.result.bookResultTest;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user