Compare commits

...

46 Commits

Author SHA1 Message Date
Patrick FELIX-VIMALARATNAM d0c7514624 test passé 2026-06-14 21:46:23 +02:00
Patrick FELIX-VIMALARATNAM fd9863097c création des test manquants 2026-06-14 21:46:23 +02:00
Maxime LEBRETON c582b54a42 suite de l'impementation 2026-06-14 21:46:23 +02:00
Maxime LEBRETON a828b0db95 début test usecase 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 4511e4e961 refactor nom fichier 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 889f17d806 refactorr d'un nom de fichier 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 8fc037e4b1 Implementation des méthode de delete ainsi que la modification des test pour qu'il fonctionne 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 0d2a88f4a0 test delete 2026-06-14 21:46:23 +02:00
Maxime LEBRETON a5c26c62e3 implementation du code 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 1ac8896253 suite test 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 4d7079c585 debut des test sur la bd 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 5b7e413a44 methode point de fidelité convert 2026-06-14 21:46:23 +02:00
Maxime LEBRETON f0704e4039 Test point de fidelité convert 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 7ba85a0ae8 ajout commandID 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 9bdccbb954 ajout test sur commandID 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 01e92154e7 rajoute du Mode de payement a tester oublie 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 42b0073297 test sur les exception 2026-06-14 21:46:23 +02:00
Maxime LEBRETON aa40ad0e3b création des test sur les validator 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 76b60297c1 création des test sur les UUID 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 3ace5810f8 création des test sur toDTO 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 28a923c126 création des test sur les entité 2026-06-14 21:46:23 +02:00
Maxime LEBRETON a93ea4fc31 premier test valider 2026-06-14 21:46:23 +02:00
Maxime LEBRETON 45d4016960 création premier test 2026-06-14 21:46:23 +02:00
Patrick FELIX-VIMALARATNAM 7c2eb19e13 réussite des test fin de cette feature 2026-06-14 16:31:03 +02:00
Patrick FELIX-VIMALARATNAM 49ddb77fb2 créationd des tests et déplacement d'un fichier qui était au mauvais endroit 2026-06-14 15:32:43 +02:00
Patrick FELIX-VIMALARATNAM 3deb17a4c7 réussite des tests 2026-06-14 14:38:27 +02:00
Patrick FELIX-VIMALARATNAM 655fad8fb2 création de tests pour le repository 2026-06-14 14:25:47 +02:00
Marvin AUBERT 5adb10101f réutilisation de la même commande que pour review parceque sinon trop long pour changer subscriptiondurationdesired en desiredsubscriptionduration 2026-06-14 00:20:14 +02:00
Marvin AUBERT 2c33798c83 réussite de tous les tests 2026-06-14 00:13:28 +02:00
Marvin AUBERT 9e69e02066 création des tests d'exception' 2026-06-14 00:00:18 +02:00
Marvin AUBERT b2969260c0 création des tests de validator 2026-06-13 23:22:40 +02:00
Marvin AUBERT 2a6db59950 mise à jour pour correspondre avec le fait que la date désiré de début d'abonnement doit être le jour même ou plus tard 2026-06-13 22:41:47 +02:00
Marvin AUBERT 5d5945b48b réussite des tests de base, c'était long 2026-06-13 16:00:03 +02:00
Marvin AUBERT da19dfcbac création des tests de converter et de entity pour subscription et paymentmethod 2026-06-13 15:08:34 +02:00
Marvin AUBERT 13f8cab3ed bonne utilisation de nom de variable en anglais pour rester cohérent pour avis via la commande
"find src/test/java/fr/iut_fbleau/but3/dev62/mylibrary/review -name "*.java" -exec sed -i 's/AVIS/REVIEW/g; s/Avis/Review/g; s/avis/review/g' {} +" pour les fichier test et remplacer le chemin pour les fichier main
2026-06-12 01:25:15 +02:00
Marvin AUBERT 1d8b4c0ac9 test passé fin du usercase 2026-06-12 01:14:00 +02:00
Marvin AUBERT 9ee039a32e modification pour meilleur logique du cas de recherche de review par livre ou utilisateur 2026-06-12 00:12:00 +02:00
Marvin AUBERT 051a8e03ed ajout de l'attribut avisID après l'oublie 2026-06-11 23:30:26 +02:00
Marvin AUBERT 1d066a802f oublie de la variable output avisId 2026-06-11 23:20:09 +02:00
Marvin AUBERT a4808a28c9 création des test pour le usecase et l'exception lors de la suppression d'un id non existant dans la table 2026-06-11 22:34:57 +02:00
Marvin AUBERT 90939326dc ajout du readme avec les membre du groupe 2026-06-11 21:02:31 +02:00
Marvin AUBERT 5cc3986307 réussite des test en fait le save recréé forcément les ID 2026-06-11 20:57:04 +02:00
Marvin AUBERT 5705081bbe oublie de changer le nom d'une méthode 2026-06-11 20:16:09 +02:00
Marvin AUBERT e11c5b744f création des test sur la BD imaginaire car oublie du cas où on peut supprimer toutes les review d'un utilisateur ou d'un livre 2026-06-11 20:14:06 +02:00
Marvin AUBERT 90929b7bdd réussite des test sur la BD imaginaire 2026-06-11 19:14:08 +02:00
Marvin AUBERT 62b4a30add création des test sur la BD imaginaire 2026-06-11 18:59:29 +02:00
67 changed files with 4334 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
Notre groupe est constitué de Marvin Aubert, Maxime Lebreton et de Patrick Felix Vimalaratnam
+12
View File
@@ -19,6 +19,12 @@
} }
}, },
"PasserCommande": { "PasserCommande": {
"input": { "input": {
"clientId": "uuid", "clientId": "uuid",
@@ -40,6 +46,12 @@
"pointsFideliteGagnes": "integer" "pointsFideliteGagnes": "integer"
} }
}, },
"GererAvis": { "GererAvis": {
"input": { "input": {
"clientId": "uuid", "clientId": "uuid",
@@ -0,0 +1,3 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
public record AdresseInfo(String rue, String ville, String codePostal, String pays) {}
@@ -0,0 +1,23 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
import lombok.Builder;
import lombok.Getter;
import java.util.List;
import java.util.UUID;
@Getter
@Builder
public class CommandeDTO {
private UUID clientId;
private List<LigneCommandeInfo> lignesCommande;
private String rue;
private String ville;
private String codePostal;
private String pays;
private String modePaiement;
private UUID commandeId ;
private double montantTotal ;
private Integer pointsFideliteGagnes ;
}
@@ -0,0 +1,6 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
import java.util.List;
public record CommandeInfo(List<LigneCommandeInfo> listeLigne , String modePayement) {
}
@@ -0,0 +1,15 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
import lombok.Builder;
import lombok.Getter;
import java.util.UUID;
@Getter
@Builder
public class LigneCommandeDTO {
int quantite;
UUID id;
}
@@ -0,0 +1,6 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
import java.util.UUID;
public record LigneCommandeInfo(int quantite) {
}
@@ -0,0 +1,7 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande;
public enum ModePaiement {
CB,
PAYPAL,
POINTS_FIDELITE,
}
@@ -0,0 +1,59 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.AdresseInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.CommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.CommandeDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
public final class CommandeConverter {
public static Commande toDomain(CommandeInfo commandeInfo, AdresseInfo adressInfo, String modePaiement) {
return Commande.builder()
.lignesCommande(commandeInfo.listeLigne())
.rue(adressInfo.rue())
.ville(adressInfo.ville())
.codePostal(adressInfo.codePostal())
.pays(adressInfo.pays())
.modePaiement(commandeInfo.modePayement())
.build();
}
public static Commande toDomain(CommandeInfo commandeInfo, AdresseInfo adressInfo) {
return Commande.builder()
.lignesCommande(commandeInfo.listeLigne())
.rue(adressInfo.rue())
.ville(adressInfo.ville())
.codePostal(adressInfo.codePostal())
.pays(adressInfo.pays())
.modePaiement(commandeInfo.modePayement())
.build();
}
public static CommandeDTO toDTO(CommandeInfo commandeInfo, AdresseInfo adressInfo, String modePaiement) {
return CommandeDTO.builder()
.lignesCommande(commandeInfo.listeLigne())
.rue(adressInfo.rue())
.ville(adressInfo.ville())
.codePostal(adressInfo.codePostal())
.pays(adressInfo.pays())
.modePaiement(modePaiement)
.build();
}
public static CommandeDTO toDTO(Commande commande) {
return CommandeDTO.builder()
.lignesCommande(commande.getLignesCommande())
.rue(commande.getRue())
.ville(commande.getVille())
.codePostal(commande.getCodePostal())
.pays(commande.getPays())
.modePaiement(commande.getModePaiement())
.commandeId(commande.getCommandeId())
.clientId(commande.getClientId())
.montantTotal(commande.getMontantTotal())
.pointsFideliteGagnes(commande.getPointsFideliteGagnes())
.build();
}
}
@@ -0,0 +1,22 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.LigneCommande;
public final class LigneCommandeConverter {
public static LigneCommande toDomain(LigneCommandeInfo ligneCommandeInfo) {
return LigneCommande.builder()
.quantite(ligneCommandeInfo.quantite())
.build();
}
public static LigneCommandeDTO toDTO(LigneCommandeInfo ligneCommandeInfo) {
return LigneCommandeDTO.builder()
.quantite(ligneCommandeInfo.quantite())
.build();
}
}
@@ -0,0 +1,44 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
import lombok.Builder;
import lombok.Getter;
import java.util.List;
import java.util.UUID;
@Getter
@Builder
public class Commande {
private UUID clientId;
private List<LigneCommandeInfo> lignesCommande;
private String rue;
private String ville;
private String codePostal;
private String pays;
private String modePaiement;
private UUID commandeId ;
private double montantTotal ;
private Integer pointsFideliteGagnes ;
public void setRandomUUID() {
this.clientId = UUID.randomUUID();
}
public void setRandomUUIDCommande() {
this.commandeId = UUID.randomUUID();
}
public int convertPointsFidelite(){
if (this.montantTotal==0|| this.montantTotal<=0){
return 0;
}
return (int) Math.ceil(this.getMontantTotal());
}
// conversion point de fidéliter
}
@@ -0,0 +1,20 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import lombok.Builder;
import lombok.Getter;
import java.util.UUID;
@Getter
@Builder
public class LigneCommande {
int quantite;
UUID livreId;
public void setRandomUUID() {
this.livreId = UUID.randomUUID();
}
}
@@ -0,0 +1,13 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception;
import java.text.MessageFormat;
import java.util.UUID;
public class CommandeNotFoundException extends RuntimeException {
public static final String THE_COMMANDE_WITH_ID_DOES_NOT_EXIST_MESSAGE = "The commande with id {0} does not exist";
public CommandeNotFoundException(UUID uuid) {
super(MessageFormat.format(THE_COMMANDE_WITH_ID_DOES_NOT_EXIST_MESSAGE, uuid));
}
}
@@ -0,0 +1,7 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception;
public class NotValidAdressException extends RuntimeException {
public NotValidAdressException(String message) {
super(message);
}
}
@@ -0,0 +1,7 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception;
public class NotValidCommandeException extends RuntimeException {
public NotValidCommandeException(String message) {
super(message);
}
}
@@ -0,0 +1,7 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception;
public class NotValidLigneCommandeException extends RuntimeException {
public NotValidLigneCommandeException(String message) {
super(message);
}
}
@@ -0,0 +1,47 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.repository;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
public class CommandeRepository {
private final List<Commande> commande = new ArrayList<>();
public List<Commande> findAll(){return commande;}
public void deleteAll() {
commande.clear();
}
public Commande save(Commande newCommande){
Optional<Commande> optionalCommandeWithSameIsbn = this.findById(newCommande.getCommandeId());
optionalCommandeWithSameIsbn.ifPresent(commande::remove);
this.commande.add(newCommande);
return newCommande;
}
public Optional<Commande> findById(UUID uuid){
return this.commande.stream()
.filter(customer -> customer.getCommandeId().equals(uuid))
.findFirst();
}
public boolean existsById(UUID uuid) {
return this.commande.stream()
.anyMatch(customer -> customer.getCommandeId().equals(uuid));
}
public void delete(Commande commande) {
this.commande.remove(commande);
}
public void deleteById(UUID uuid) {
this.commande.removeIf(commande -> commande.getClientId().equals(uuid));
}
}
@@ -0,0 +1,73 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.usecase;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.AdresseInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.CommandeDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.CommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.converter.CommandeConverter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.CommandeNotFoundException;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.NotValidCommandeException;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.repository.CommandeRepository;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.validator.CommandeValidator;
import java.util.Optional;
import java.util.UUID;
public class CommandeUseCase {
private final CommandeRepository commandeRepository;
public CommandeUseCase(CommandeRepository commandeRepository) {
this.commandeRepository = commandeRepository;
}
public UUID registerCommande(CommandeInfo validCommandeInfo, AdresseInfo validAdresseInfo){
CommandeValidator.validate(validCommandeInfo);
CommandeValidator.validate(validAdresseInfo);
Commande commandeToRegister = CommandeConverter.toDomain(validCommandeInfo,validAdresseInfo);
Commande commandeToRegistered = commandeRepository.save(commandeToRegister) ;
return commandeToRegistered.getCommandeId();
}
public Optional<CommandeDTO> findCommandByUUID(UUID uuid) {
Optional<Commande> optionalCommande = commandeRepository.findById(uuid);
return optionalCommande.map(CommandeConverter::toDTO);
}
public CommandeDTO updateCommande(UUID uuid, CommandeInfo commandeInfo, AdresseInfo adresseInfo)
throws CommandeNotFoundException, NotValidCommandeException {
CommandeValidator.validate(commandeInfo);
CommandeValidator.validate(adresseInfo);
Commande commandeByUUID = getCommandeIfDoesNotExistThrowCommandeNotFoundException(
uuid);
Commande commande = Commande.builder()
.clientId(commandeByUUID.getClientId())
.lignesCommande(commandeInfo.listeLigne())
.rue(adresseInfo.rue())
.ville(adresseInfo.ville())
.codePostal(adresseInfo.codePostal())
.pays(adresseInfo.pays())
.modePaiement(commandeInfo.modePayement())
.commandeId(uuid)
.build();
Commande updatedCommande = commandeRepository.save(commande);
return CommandeConverter.toDTO(updatedCommande);
}
public void deleteCommande(UUID uuid) throws CommandeNotFoundException {
Commande commandeToDelete = getCommandeIfDoesNotExistThrowCommandeNotFoundException(uuid);
this.commandeRepository.delete(commandeToDelete);
}
private Commande getCommandeIfDoesNotExistThrowCommandeNotFoundException(UUID uuid)
throws CommandeNotFoundException {
Optional<Commande> optionalCommandeById = commandeRepository.findById(uuid);
if (optionalCommandeById.isEmpty()) {
throw new CommandeNotFoundException(uuid);
}
return optionalCommandeById.get();
}
}
@@ -0,0 +1,87 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.validator;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.AdresseInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.CommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.NotValidAdressException;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.NotValidCommandeException;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.NotValidLigneCommandeException;
import java.util.Objects;
public final class CommandeValidator {
public static final String LIGNE_COMMANDE_IS_NOT_VALIDE = "Ligne commande is not valide";
public static final String MODE_PAIEMENT_IS_NOT_VALIDE = "Mode Paiement is not valide";
public static final String LIST_LIGNE_COMANDE_IS_NOT_VALIDE = "List ligne commande is not valide";
public static final String STREET_IS_NOT_VALIDE = "rue is not valide";
public static final String CITY_IS_NOT_VALIDE = "city is not valide";
public static final String CODE_POSTAL_IS_NOT_VALIDE = "code postal is not valide";
public static final String COUNTRY_IS_NOT_VALIDE = "Country is not valide";
public static void validate(LigneCommandeInfo ligneCommandeInfo) {
if (ligneCommandeInfo.quantite()<=0){
throw new NotValidLigneCommandeException(LIGNE_COMMANDE_IS_NOT_VALIDE);
}
}
public static void validate(CommandeInfo commandeInfo) {
validateModePaiement(commandeInfo);
validateListLigneCommande(commandeInfo);
}
public static void validate(AdresseInfo adresseInfo) {
validateStreet(adresseInfo);
validateCity(adresseInfo);
validateCodePostal(adresseInfo);
validateCountry(adresseInfo);
}
private static void validateModePaiement(CommandeInfo commandeInfo) {
if(commandeInfo.modePayement()!="CB"&& commandeInfo.modePayement()!="PAYPAL"&& commandeInfo.modePayement()!="POINTS_FIDELITE"){
throw new NotValidCommandeException(MODE_PAIEMENT_IS_NOT_VALIDE);
}
}
private static void validateListLigneCommande(CommandeInfo commandeInfo) {
if (commandeInfo.listeLigne() == null
|| commandeInfo.listeLigne().isEmpty()
|| commandeInfo.listeLigne().stream().anyMatch(Objects::isNull)){
throw new NotValidCommandeException(LIST_LIGNE_COMANDE_IS_NOT_VALIDE);
}
}
private static void validateStreet(AdresseInfo adresseInfo) {
if (adresseInfo.rue() == null || adresseInfo.rue().isBlank()){
throw new NotValidAdressException(STREET_IS_NOT_VALIDE);
}
}
private static void validateCity(AdresseInfo adresseInfo) {
if (adresseInfo.ville() == null || adresseInfo.ville().isBlank()){
throw new NotValidAdressException(CITY_IS_NOT_VALIDE);
}
}
private static void validateCodePostal(AdresseInfo adresseInfo) {
if (adresseInfo.codePostal() == null || adresseInfo.codePostal().isBlank()){
throw new NotValidAdressException(CODE_POSTAL_IS_NOT_VALIDE);
}
}
private static void validateCountry(AdresseInfo adresseInfo) {
if (adresseInfo.pays() == null || adresseInfo.pays().isBlank()){
throw new NotValidAdressException(COUNTRY_IS_NOT_VALIDE);
}
}
}
@@ -10,6 +10,7 @@ import java.util.UUID;
@Builder @Builder
public class ReviewDTO { public class ReviewDTO {
private UUID reviewId;
private UUID customerId; private UUID customerId;
private UUID bookId; private UUID bookId;
private Integer note; private Integer note;
@@ -1,6 +1,7 @@
package fr.iut_fbleau.but3.dev62.mylibrary.review; package fr.iut_fbleau.but3.dev62.mylibrary.review;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.UUID;
public record ReviewInfo(Integer note, String comment, LocalDate purchaseDate) { public record ReviewInfo(Integer note, String comment, LocalDate purchaseDate) {
} }
@@ -19,6 +19,7 @@ public class ReviewConverter {
public static ReviewDTO toDTO(Review review) { public static ReviewDTO toDTO(Review review) {
return ReviewDTO.builder() return ReviewDTO.builder()
.reviewId(review.getReviewId())
.customerId(review.getCustomerId()) .customerId(review.getCustomerId())
.bookId(review.getBookId()) .bookId(review.getBookId())
.note(review.getNote()) .note(review.getNote())
@@ -10,6 +10,7 @@ import java.util.UUID;
@Builder @Builder
public class Review { public class Review {
private UUID reviewId;
private UUID customerId; private UUID customerId;
private UUID bookId; private UUID bookId;
private Integer note; private Integer note;
@@ -17,6 +18,10 @@ public class Review {
private LocalDate purchaseDate; private LocalDate purchaseDate;
public void setRandomUUID() { public void setRandomUUID() {
this.reviewId = UUID.randomUUID();
}
public void setRandomUUIDCustomerAndBook() {
this.customerId = UUID.randomUUID(); this.customerId = UUID.randomUUID();
this.bookId = UUID.randomUUID(); this.bookId = UUID.randomUUID();
@@ -0,0 +1,25 @@
package fr.iut_fbleau.but3.dev62.mylibrary.review.exception;
import java.text.MessageFormat;
import java.util.Optional;
import java.util.UUID;
public class ReviewNotFoundException extends RuntimeException {
public static final String THE_REVIEWS_WITH_CUSTOMER_ID_DOES_NOT_EXIST_MESSAGE = "The reviews with the customer id {0} does not exists";
public static final String THE_REVIEWS_WITH_BOOK_ID_DOES_NOT_EXIST_MESSAGE = "The reviews with the book id {0} does not exists";
public static final String THE_REVIEWS_WITH_REVIEW_ID_DOES_NOT_EXIST_MESSAGE = "The review with review id {0} does not exists";
public ReviewNotFoundException(Optional<UUID> customerUUID, Optional<UUID> bookUUID, Optional<UUID> reviewUUID) {
super(buildMessage(customerUUID, bookUUID, reviewUUID));
}
private static String buildMessage(Optional<UUID> customerUUID, Optional<UUID> bookUUID, Optional<UUID> reviewUUID) {
if (customerUUID.isPresent()) {
return MessageFormat.format(THE_REVIEWS_WITH_CUSTOMER_ID_DOES_NOT_EXIST_MESSAGE, customerUUID.get());
}else if (bookUUID.isPresent()) {
return MessageFormat.format(THE_REVIEWS_WITH_BOOK_ID_DOES_NOT_EXIST_MESSAGE, bookUUID.get());
}
return MessageFormat.format(THE_REVIEWS_WITH_REVIEW_ID_DOES_NOT_EXIST_MESSAGE, reviewUUID.get());
}
}
@@ -0,0 +1,79 @@
package fr.iut_fbleau.but3.dev62.mylibrary.review.repository;
import fr.iut_fbleau.but3.dev62.mylibrary.review.entity.Review;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
public class ReviewRepository {
private final List<Review> reviews = new ArrayList<>();
public List<Review> findAll() {
return reviews;
}
public void deleteAll() {
reviews.clear();
}
public Review save(Review newReview) {
Optional<Review> optionalReviewWithSameReviewId = this.findByReviewId(newReview.getReviewId());
optionalReviewWithSameReviewId.ifPresent(reviews::remove);
this.reviews.add(newReview);
return newReview;
}
public ArrayList<Review> findByCustomerId(UUID customerUUID) {
return this.reviews.stream()
.filter(review -> review.getCustomerId().equals(customerUUID))
.collect(Collectors.toCollection(ArrayList::new));
}
public ArrayList<Review> findByBookId(UUID bookUUID) {
return this.reviews.stream()
.filter(review -> review.getBookId().equals(bookUUID))
.collect(Collectors.toCollection(ArrayList::new));
}
public Optional<Review> findByReviewId(UUID reviewUUID) {
return this.reviews.stream()
.filter(review -> review.getReviewId().equals(reviewUUID))
.findFirst();
}
public boolean existsByCustomerId(UUID customerUUID) {
return this.reviews.stream()
.anyMatch(review -> review.getCustomerId().equals(customerUUID));
}
public boolean existsByBookId(UUID bookUUID) {
return this.reviews.stream()
.anyMatch(review -> review.getBookId().equals(bookUUID));
}
public boolean existsByReviewId(UUID reviewUUID) {
return this.reviews.stream()
.anyMatch(review -> review.getReviewId().equals(reviewUUID));
}
public void deleteCustomerReviews(UUID customerUUID) {
this.reviews.removeIf(review -> review.getCustomerId().equals(customerUUID));
}
public void deleteBookReviews(UUID bookUUID) {
this.reviews.removeIf(review -> review.getBookId().equals(bookUUID));
}
public void delete(Review review) {
this.reviews.remove(review);
}
}
@@ -0,0 +1,113 @@
package fr.iut_fbleau.but3.dev62.mylibrary.review.usecase;
import fr.iut_fbleau.but3.dev62.mylibrary.review.ReviewDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.review.ReviewInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.review.converter.ReviewConverter;
import fr.iut_fbleau.but3.dev62.mylibrary.review.entity.Review;
import fr.iut_fbleau.but3.dev62.mylibrary.review.exception.NotValidReviewException;
import fr.iut_fbleau.but3.dev62.mylibrary.review.exception.ReviewNotFoundException;
import fr.iut_fbleau.but3.dev62.mylibrary.review.repository.ReviewRepository;
import fr.iut_fbleau.but3.dev62.mylibrary.review.validator.ReviewValidator;
import java.util.ArrayList;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
public class ReviewUseCase {
private final ReviewRepository reviewRepository;
public ReviewUseCase(ReviewRepository reviewRepository) {
this.reviewRepository = reviewRepository;
}
public UUID registerReview(ReviewInfo newReview) throws NotValidReviewException {
ReviewValidator.validate(newReview);
Review reviewToRegister = ReviewConverter.toDomain(newReview);
Review reviewToRegistered = reviewRepository.save(reviewToRegister);
return reviewToRegistered.getReviewId();
}
public ArrayList<ReviewDTO> findReviewByCustomerId(UUID customerId) {
ArrayList<Review> optionalReviews = reviewRepository.findByCustomerId(customerId);
return optionalReviews.stream()
.map(ReviewConverter::toDTO)
.collect(Collectors.toCollection(ArrayList::new));
}
public ArrayList<ReviewDTO> findReviewByBookId(UUID bookId) {
ArrayList<Review> optionalReviews = reviewRepository.findByBookId(bookId);
return optionalReviews.stream()
.map(ReviewConverter::toDTO)
.collect(Collectors.toCollection(ArrayList::new));
}
public Optional<ReviewDTO> findReviewByReviewId(UUID reviewId) {
Optional<Review> optionalReview = reviewRepository.findByReviewId(reviewId);
return optionalReview.map(ReviewConverter::toDTO);
}
public ReviewDTO updateReview(UUID reviewUUID, ReviewInfo reviewInfo)
throws ReviewNotFoundException, NotValidReviewException {
ReviewValidator.validate(reviewInfo);
Review reviewByReviewUUID = getReviewIfDoesNotExistThrowReviewNotFoundException(
reviewUUID);
Review review = Review.builder()
.reviewId(reviewUUID)
.customerId(reviewByReviewUUID.getCustomerId())
.bookId(reviewByReviewUUID.getBookId())
.note(reviewByReviewUUID.getNote())
.comment(reviewByReviewUUID.getComment())
.purchaseDate(reviewByReviewUUID.getPurchaseDate())
.build();
Review updatedReview = reviewRepository.save(review);
return ReviewConverter.toDTO(updatedReview);
}
public void deleteReview(UUID reviewUUID) throws ReviewNotFoundException {
Review reviewToDelete = getReviewIfDoesNotExistThrowReviewNotFoundException(reviewUUID);
this.reviewRepository.delete(reviewToDelete);
}
public void deleteCustomerReviews(UUID customerUUID) throws ReviewNotFoundException {
ArrayList<Review> reviewsToDelete = getReviewByCustomerIdIfDoesNotExistThrowReviewNotFoundException(customerUUID);
for (Review review : reviewsToDelete) {
reviewRepository.delete(review);
}
}
public void deleteBookReviews(UUID bookUUID) throws ReviewNotFoundException {
ArrayList<Review> reviewsToDelete = getReviewByBookIfDoesNotExistThrowReviewNotFoundException(bookUUID);
for (Review review : reviewsToDelete) {
reviewRepository.delete(review);
}
}
private Review getReviewIfDoesNotExistThrowReviewNotFoundException(UUID reviewUUID)
throws ReviewNotFoundException {
Optional<Review> optionalReviewByReviewId = reviewRepository.findByReviewId(reviewUUID);
if (optionalReviewByReviewId.isEmpty()) {
throw new ReviewNotFoundException(Optional.empty(), Optional.empty(),Optional.of(reviewUUID));
}
return optionalReviewByReviewId.get();
}
private ArrayList<Review> getReviewByCustomerIdIfDoesNotExistThrowReviewNotFoundException(UUID customerUUID)
throws ReviewNotFoundException {
ArrayList<Review> optionalReviewByReviewId = reviewRepository.findByCustomerId(customerUUID);
if (optionalReviewByReviewId.isEmpty()) {
throw new ReviewNotFoundException(Optional.of(customerUUID), Optional.empty(),Optional.empty());
}
return optionalReviewByReviewId;
}
private ArrayList<Review> getReviewByBookIfDoesNotExistThrowReviewNotFoundException(UUID bookUUID)
throws ReviewNotFoundException {
ArrayList<Review> optionalReviewByReviewId = reviewRepository.findByBookId(bookUUID);
if (optionalReviewByReviewId.isEmpty()) {
throw new ReviewNotFoundException(Optional.empty(), Optional.empty(), Optional.of(bookUUID));
}
return optionalReviewByReviewId;
}
}
@@ -0,0 +1,17 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
public enum DesiredSubscriptionDuration {
THREE(3),
SIX(6),
TWELVE(12);
private final Integer value;
DesiredSubscriptionDuration(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
}
@@ -0,0 +1,4 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
public record PaymentMethodInfo(String paymentType, Object details) {
}
@@ -0,0 +1,6 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
public enum PaymentType {
CB,
PAYPAL;
}
@@ -0,0 +1,22 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.PaymentMethod;
import lombok.Builder;
import lombok.Getter;
import java.time.LocalDate;
import java.util.UUID;
@Builder
@Getter
public class SubscriptionDTO {
private UUID subscriptionId;
private UUID customerId;
private Integer desiredSubscriptionDuration;
private PaymentMethod paymentMethod;
private LocalDate desiredStartDate;
private LocalDate startDate;
private LocalDate endDate;
private double monthlyAmount;
}
@@ -0,0 +1,6 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
import java.time.LocalDate;
public record SubscriptionInfo(Integer desiredSubscriptionDuration, LocalDate desiredStartDate) {
}
@@ -0,0 +1,43 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.customer.CustomerDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.PaymentMethodInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.PaymentMethod;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.Subscription;
public class SubscriptionConverter {
private SubscriptionConverter(){
}
public static Subscription toDomain(SubscriptionInfo newSubscription, PaymentMethodInfo newPaymentMethod) {
PaymentMethod paymentMethod = PaymentMethod.builder()
.paymentType(newPaymentMethod.paymentType())
.details(newPaymentMethod.details())
.build();
return Subscription.builder()
.desiredSubscriptionDuration(newSubscription.desiredSubscriptionDuration())
.paymentMethod(paymentMethod)
.desiredStartDate(newSubscription.desiredStartDate())
.startDate(newSubscription.desiredStartDate())
.endDate(newSubscription.desiredStartDate().plusMonths(newSubscription.desiredSubscriptionDuration()))
.monthlyAmount(0)
.build();
}
public static SubscriptionDTO toDTO(Subscription subscription) {
return SubscriptionDTO.builder()
.subscriptionId(subscription.getSubscriptionId())
.customerId(subscription.getCustomerId())
.desiredSubscriptionDuration(subscription.getDesiredSubscriptionDuration())
.paymentMethod(subscription.getPaymentMethod())
.desiredStartDate(subscription.getDesiredStartDate())
.startDate(subscription.getStartDate())
.endDate(subscription.getEndDate())
.monthlyAmount(subscription.getMonthlyAmount())
.build();
}
}
@@ -0,0 +1,12 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity;
import lombok.Builder;
import lombok.Getter;
@Builder
@Getter
public class PaymentMethod {
private String paymentType;
private Object details;
}
@@ -0,0 +1,44 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity;
import lombok.Builder;
import lombok.Getter;
import java.time.LocalDate;
import java.util.UUID;
@Builder
@Getter
public class Subscription {
private UUID subscriptionId;
private UUID customerId;
private Integer desiredSubscriptionDuration;
private PaymentMethod paymentMethod;
private LocalDate desiredStartDate;
private LocalDate startDate;
private LocalDate endDate;
private double monthlyAmount;
public void setRandomSubscriptionUUID() {
this.subscriptionId = UUID.randomUUID();
}
public void setRandomCustomerUUID() {
this.customerId = UUID.randomUUID();
}
public void setStartDate(){
this.startDate = this.desiredStartDate;
}
public void setEndDate(){
this.endDate = this.desiredStartDate.plusMonths(this.desiredSubscriptionDuration);
}
public void setDateSubscription(){
setStartDate();
setEndDate();
}
}
@@ -0,0 +1,8 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.exception;
public class NotValidPaymentMethodException extends RuntimeException {
public NotValidPaymentMethodException(String message) {
super(message);
}
}
@@ -0,0 +1,8 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.exception;
public class NotValidSubscriptionException extends RuntimeException {
public NotValidSubscriptionException(String message) {
super(message);
}
}
@@ -0,0 +1,21 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.exception;
import java.text.MessageFormat;
import java.util.Optional;
import java.util.UUID;
public class SubscriptionNotFoundException extends RuntimeException {
public static final String THE_SUBSCRIPTION_WITH_CUSTOMER_ID_DOES_NOT_EXIST_MESSAGE = "The subscriptions with the customer id {0} does not exists";
public static final String THE_SUBSCRIPTION_WITH_SUBSCRIPTION_ID_DOES_NOT_EXIST_MESSAGE = "The subscription with subscription id {0} does not exists";
public SubscriptionNotFoundException(Optional<UUID> customerUUID, Optional<UUID> subscriptionUUID) {
super(buildMessage(customerUUID, subscriptionUUID));
}
private static String buildMessage(Optional<UUID> customerUUID, Optional<UUID> subscriptionUUID) {
if (customerUUID.isPresent()) {
return MessageFormat.format(THE_SUBSCRIPTION_WITH_CUSTOMER_ID_DOES_NOT_EXIST_MESSAGE, customerUUID.get());
}
return MessageFormat.format(THE_SUBSCRIPTION_WITH_SUBSCRIPTION_ID_DOES_NOT_EXIST_MESSAGE, subscriptionUUID.get());
}
}
@@ -0,0 +1,62 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.repository;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.Subscription;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
public class SubscriptionRepository {
private final List<Subscription> subscriptions = new ArrayList<>();
public List<Subscription> findAll() {
return subscriptions;
}
public void deleteAll() {
subscriptions.clear();
}
public Subscription save(Subscription newSubscription) {
Optional<Subscription> optionalSubscriptionWithSameSubscriptionId = this.findBySubscriptionId(newSubscription.getSubscriptionId());
optionalSubscriptionWithSameSubscriptionId.ifPresent(subscriptions::remove);
this.subscriptions.add(newSubscription);
return newSubscription;
}
public List<Subscription> FindByCustomerId(UUID customerUUID) {
return this.subscriptions.stream()
.filter(subscription -> subscription.getCustomerId().equals(customerUUID))
.toList();
}
public Optional<Subscription> findBySubscriptionId(UUID subscriptionUUID) {
return this.subscriptions.stream()
.filter(subscription -> subscription.getSubscriptionId().equals(subscriptionUUID))
.findFirst();
}
public boolean existsByCustomerId(UUID customerUUID) {
return this.subscriptions.stream()
.anyMatch(review -> review.getCustomerId().equals(customerUUID));
}
public boolean existsBySubscriptionId(UUID subscriptionUUID) {
return this.subscriptions.stream()
.anyMatch(subscription -> subscription.getSubscriptionId().equals(subscriptionUUID));
}
public void deleteByCustomerId(UUID customerUUID) {
this.subscriptions.removeIf(subscription -> subscription.getCustomerId().equals(customerUUID));
}
public void delete(Subscription subscription) {
this.subscriptions.remove(subscription);
}
}
@@ -0,0 +1,110 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.usecase;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.PaymentMethodInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.converter.SubscriptionConverter;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.PaymentMethod;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.Subscription;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.exception.NotValidSubscriptionException;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.exception.SubscriptionNotFoundException;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.repository.SubscriptionRepository;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.validator.PaymentMethodValidator;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.validator.SubscriptionValidator;
import java.util.*;
public class SubscriptionUseCase {
private final SubscriptionRepository subscriptionRepository;
public SubscriptionUseCase(SubscriptionRepository subscriptionRepository) {
this.subscriptionRepository = subscriptionRepository;
}
private Map<String, Object> Output(Subscription subscription){
Map<String, Object> result = new HashMap<>();
result.put("subscriptionId", subscription.getSubscriptionId());
result.put("startDate", subscription.getStartDate());
result.put("endDate", subscription.getEndDate());
result.put("monthlyAmount", subscription.getMonthlyAmount());
return result;
}
public Map<String, Object> registerSubscription(SubscriptionInfo newSubscription, PaymentMethodInfo newPaymentMethod)
throws NotValidSubscriptionException {
SubscriptionValidator.validate(newSubscription);
PaymentMethodValidator.validate(newPaymentMethod);
Subscription subscriptionToRegister = SubscriptionConverter.toDomain(newSubscription, newPaymentMethod);
Subscription subscriptionToRegistered = subscriptionRepository.save(subscriptionToRegister);
return Output(subscriptionToRegistered);
}
public List<SubscriptionDTO> findSubscriptionByCustomerId(UUID customerId) {
List<Subscription> optionalSubscriptions = subscriptionRepository.FindByCustomerId(customerId);
return optionalSubscriptions.stream()
.map(SubscriptionConverter::toDTO)
.toList();
}
public Optional<SubscriptionDTO> findSubscriptionBySubscriptionId(UUID subscriptionId) {
Optional<Subscription> optionalSubscription = subscriptionRepository.findBySubscriptionId(subscriptionId);
return optionalSubscription.map(SubscriptionConverter::toDTO);
}
public SubscriptionDTO updateSubscription(UUID SubscriptionUUID, SubscriptionInfo subscriptionInfo, PaymentMethodInfo paymentMethodInfo)
throws SubscriptionNotFoundException, NotValidSubscriptionException {
SubscriptionValidator.validate(subscriptionInfo);
PaymentMethodValidator.validate(paymentMethodInfo);
Subscription subscriptionBySubscriptionUUID = getSubscriptionIfDoesNotExistThrowSubscriptionNotFoundException(
SubscriptionUUID);
PaymentMethod paymentMethod = PaymentMethod.builder()
.paymentType(paymentMethodInfo.paymentType())
.details(paymentMethodInfo.details())
.build();
Subscription subscription = Subscription.builder()
.subscriptionId(SubscriptionUUID)
.customerId(subscriptionBySubscriptionUUID.getCustomerId())
.desiredSubscriptionDuration(subscriptionInfo.desiredSubscriptionDuration())
.paymentMethod(paymentMethod)
.desiredStartDate(subscriptionInfo.desiredStartDate())
.monthlyAmount(subscriptionBySubscriptionUUID.getMonthlyAmount())
.build();
subscription.setDateSubscription();
Subscription updatedSubscription = subscriptionRepository.save(subscription);
return SubscriptionConverter.toDTO(updatedSubscription);
}
public void deleteSubscription(UUID subscriptionUUID) throws SubscriptionNotFoundException {
Subscription subscriptionToDelete = getSubscriptionIfDoesNotExistThrowSubscriptionNotFoundException(subscriptionUUID);
this.subscriptionRepository.delete(subscriptionToDelete);
}
public void deleteSubscriptionsOfACustomer(UUID customerUUID) throws SubscriptionNotFoundException {
List<Subscription> subscriptionsToDelete = getSubscriptionByCustomerIdIfDoesNotExistThrowSubscriptionNotFoundException(customerUUID);
for (Subscription subscription : subscriptionsToDelete) {
subscriptionRepository.delete(subscription);
}
}
private Subscription getSubscriptionIfDoesNotExistThrowSubscriptionNotFoundException(UUID subscriptionUUID)
throws SubscriptionNotFoundException {
Optional<Subscription> optionalSubscriptionBySubscriptionId = subscriptionRepository.findBySubscriptionId(subscriptionUUID);
if (optionalSubscriptionBySubscriptionId.isEmpty()) {
throw new SubscriptionNotFoundException(Optional.empty(),Optional.of(subscriptionUUID));
}
return optionalSubscriptionBySubscriptionId.get();
}
private List<Subscription> getSubscriptionByCustomerIdIfDoesNotExistThrowSubscriptionNotFoundException(UUID customerUUID)
throws SubscriptionNotFoundException {
List<Subscription> optionalSubscriptionBySubscriptionId = subscriptionRepository.FindByCustomerId(customerUUID);
if (optionalSubscriptionBySubscriptionId.isEmpty()) {
throw new SubscriptionNotFoundException(Optional.of(customerUUID),Optional.empty());
}
return optionalSubscriptionBySubscriptionId;
}
}
@@ -0,0 +1,27 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.validator;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.PaymentMethodInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.exception.NotValidPaymentMethodException;
import java.util.Set;
public class PaymentMethodValidator {
public static final String MODE_PAIEMENT_IS_NOT_VALID = "paymentType is not valid";
private PaymentMethodValidator() {
}
public static void validate(PaymentMethodInfo newPaymentMethod)
throws NotValidPaymentMethodException {
validatePaymentType(newPaymentMethod);
}
private static void validatePaymentType(PaymentMethodInfo newPaymentMethod)
throws NotValidPaymentMethodException {
Set<String> Valid_Payment_Type = Set.of("CB", "PAYPAL");
if (!Valid_Payment_Type.contains(newPaymentMethod.paymentType())) {
throw new NotValidPaymentMethodException(MODE_PAIEMENT_IS_NOT_VALID);}
}
}
@@ -0,0 +1,36 @@
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.validator;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.exception.NotValidSubscriptionException;
import java.time.LocalDate;
import java.util.Set;
public class SubscriptionValidator {
public static final String SUBSCRIPTION_DURATION_DESIRED_IS_NOT_VALID = "desiredSubscriptionDuration will be 3, 6 or 12 by the ENUM file SubscriptionDurationDesired";
public static final String DESIRED_START_DATE_CANNOT_BE_BEFORE_TODAY = "desiredStartDate cannot be before today";
private SubscriptionValidator() {
}
public static void validate(SubscriptionInfo newSubscription) throws NotValidSubscriptionException {
validateDesiredStartDate(newSubscription);
validateSubscriptionDurationDesired(newSubscription);
}
private static void validateSubscriptionDurationDesired(SubscriptionInfo newSubscription)
throws NotValidSubscriptionException {
Set<Integer> VALID_DURATIONS = Set.of(3, 6, 12);
if (!VALID_DURATIONS.contains(newSubscription.desiredSubscriptionDuration())) {
throw new NotValidSubscriptionException(SUBSCRIPTION_DURATION_DESIRED_IS_NOT_VALID);}
}
private static void validateDesiredStartDate(SubscriptionInfo newSubscription)
throws NotValidSubscriptionException {
if (newSubscription.desiredStartDate().isBefore(LocalDate.now())) {
throw new NotValidSubscriptionException(DESIRED_START_DATE_CANNOT_BE_BEFORE_TODAY);
}
}
}
@@ -0,0 +1,65 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.*;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class CommandeConverterTest {
@Test
void TestConvertCommandeToDomain(){
String modePaiement = ModePaiement.CB.name();
List<LigneCommandeInfo> listLigne = new ArrayList<>();
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
LigneCommandeInfo ligne2 = new LigneCommandeInfo(14);
listLigne.add(ligne);
listLigne.add(ligne2);
CommandeInfo commandeInfo = new CommandeInfo(listLigne,modePaiement);
AdresseInfo adressInfo = new AdresseInfo("rue du cheval","La Rochette","77000","France");
Commande result = CommandeConverter.toDomain(commandeInfo,adressInfo,modePaiement);
assertNotNull(result);
assertEquals(commandeInfo.listeLigne(), result.getLignesCommande());
assertEquals(adressInfo.rue() , result.getRue());
assertEquals(adressInfo.ville() , result.getVille());
assertEquals(adressInfo.codePostal() , result.getCodePostal());
assertEquals(adressInfo.pays() , result.getPays());
assertEquals( modePaiement,result.getModePaiement());
}
@Test
void TestConvertCommandeToDTO(){
String modePaiement = ModePaiement.CB.name();
List<LigneCommandeInfo> listLigne = new ArrayList<>();
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
LigneCommandeInfo ligne2 = new LigneCommandeInfo(14);
listLigne.add(ligne);
listLigne.add(ligne2);
CommandeInfo commandeInfo = new CommandeInfo(listLigne,modePaiement);
AdresseInfo adressInfo = new AdresseInfo("rue du cheval","La Rochette","77000","France");
CommandeDTO result = CommandeConverter.toDTO(commandeInfo,adressInfo,modePaiement);
assertNotNull(result);
assertEquals(commandeInfo.listeLigne(), result.getLignesCommande());
assertEquals(adressInfo.rue() , result.getRue());
assertEquals(adressInfo.ville() , result.getVille());
assertEquals(adressInfo.codePostal() , result.getCodePostal());
assertEquals(adressInfo.pays() , result.getPays());
assertEquals( modePaiement,result.getModePaiement());
}
}
@@ -0,0 +1,35 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.converter;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeDTO;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.LigneCommande;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class LigneCommandeConverterTest {
@Test
void TestConvertLigneCommandeToDomain(){
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
LigneCommande result = LigneCommandeConverter.toDomain(ligne);
assertEquals(ligne.quantite(),result.getQuantite());
}
@Test
void TestConvertLigneCommandeToDTO(){
LigneCommandeInfo ligne = new LigneCommandeInfo(12);
LigneCommandeDTO result = LigneCommandeConverter.toDTO(ligne);
assertEquals(ligne.quantite(),result.getQuantite());
}
}
@@ -0,0 +1,104 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*;
public class CommandeTest {
@Test
public void commandeTest(){
UUID clientId = UUID.randomUUID();
List<LigneCommandeInfo> lignesCommande = new ArrayList<>();
LigneCommandeInfo commande1 = new LigneCommandeInfo(12);
LigneCommandeInfo commande2 = new LigneCommandeInfo(13);
lignesCommande.add(commande1);
lignesCommande.add(commande2);
String rue = "rue du chien" ;
String ville = "LKa Rochette" ;
String codePostal = "7700" ;
String pays = "France" ;
String modePayement = ModePaiement.CB.name() ;
Commande commande = Commande.builder()
.clientId(clientId)
.lignesCommande(lignesCommande)
.rue(rue)
.ville(ville)
.codePostal(codePostal)
.pays(pays)
.modePaiement(modePayement)
.build();
assertEquals(clientId, commande.getClientId());
assertEquals(lignesCommande, commande.getLignesCommande());
assertEquals(rue, commande.getRue());
assertEquals(ville, commande.getVille());
assertEquals(codePostal, commande.getCodePostal());
assertEquals(pays, commande.getPays());
assertEquals(modePayement, commande.getModePaiement());
}
@Test
@DisplayName("setRandomUUID should change the ID to a new random UUID")
void testSetRandomUUID() {
Commande commande = Commande.builder().build();
UUID originalId = commande.getClientId();
commande.setRandomUUID();
assertNotNull(commande.getClientId());
assertNotEquals(originalId, commande.getClientId());
}
@Test
@DisplayName("setRandomUUID should change the ID to a new random UUID")
void testSetRandomUUIDForCommande() {
Commande commande = Commande.builder().build();
UUID originalId = commande.getCommandeId();
commande.setRandomUUIDCommande();
assertNotNull(commande.getCommandeId());
assertNotEquals(originalId, commande.getCommandeId());
}
@Test
void testConvertPointsFideliteGagnes(){
Commande commande = Commande.builder()
.montantTotal(14.34)
.build();
Integer point = commande.convertPointsFidelite();
assertEquals(point,(int) Math.ceil(commande.getMontantTotal()));
}
@ParameterizedTest
@ValueSource(doubles = {-1.9,0.0})
void testConvertPointsFideliteGagnesWhenMontantTotalIsNotGood(){
Commande commande = Commande.builder()
.montantTotal(14.34)
.build();
Integer point = commande.convertPointsFidelite();
assertEquals(point,(int) Math.ceil(commande.getMontantTotal()));
}
}
@@ -0,0 +1,41 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.entity;
import fr.iut_fbleau.but3.dev62.mylibrary.customer.entity.Customer;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*;
public class LigneCommandeTest {
@Test
@DisplayName("Builder should create a valid LigneCommande instance")
void TestLigneCommande() {
UUID id = UUID.randomUUID();
int quantite = 12;
LigneCommande ligneCommande = LigneCommande.builder()
.livreId(id)
.quantite(quantite)
.build();
assertEquals(id, ligneCommande.getLivreId());
assertEquals(quantite, ligneCommande.getQuantite());
}
@Test
@DisplayName("setRandomUUID should change the ID to a new random UUID")
void testSetRandomUUID() {
LigneCommande ligneCommande = LigneCommande.builder().build();
UUID originalId = ligneCommande.getLivreId();
ligneCommande.setRandomUUID();
assertNotNull(ligneCommande.getLivreId());
assertNotEquals(originalId, ligneCommande.getLivreId());
}
}
@@ -0,0 +1,50 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.valid;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.CommandeNotFoundException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class CommandeNotFoundEsceptionTest {
@Test
@DisplayName("Exception message should contain the UUID provided")
void testExceptionMessageContainsUUID() {
UUID uuid = UUID.randomUUID();
CommandeNotFoundException exception = new CommandeNotFoundException(uuid);
String expectedMessage = String.format("The commande with id %s does not exist", uuid);
assertEquals(expectedMessage, exception.getMessage());
}
@Test
@DisplayName("Exception should use the correct constant message format")
void testExceptionUsesConstantMessageFormat() {
UUID uuid = UUID.randomUUID();
CommandeNotFoundException exception = new CommandeNotFoundException(uuid);
String expectedFormatWithPlaceholder = "The commande with id {0} does not exist";
assertEquals(CommandeNotFoundException.THE_COMMANDE_WITH_ID_DOES_NOT_EXIST_MESSAGE,
expectedFormatWithPlaceholder);
assertTrue(exception.getMessage().contains(uuid.toString()));
}
@Test
@DisplayName("Exception should be properly thrown and caught")
void testExceptionCanBeThrownAndCaught() {
UUID uuid = UUID.randomUUID();
try {
throw new CommandeNotFoundException(uuid);
} catch (CommandeNotFoundException e) {
String expectedMessage = String.format("The commande with id %s does not exist", uuid);
assertEquals(expectedMessage, e.getMessage());
}
}
}
@@ -0,0 +1,67 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.valid;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.NotValidAdressException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class NotValidAdressExceptionTest {
@Test
@DisplayName("Exception should be created with the provided message")
void testExceptionCreation() {
String errorMessage = "Adresse is not valid";
NotValidAdressException exception = new NotValidAdressException(errorMessage);
assertEquals(errorMessage, exception.getMessage());
}
@ParameterizedTest
@ValueSource(strings = {
"rue is not valide",
"city is not valide",
"code postal is not valide",
"Country is not valide"
})
@DisplayName("Exception should handle different validation messages")
void testExceptionWithDifferentMessages(String errorMessage) {
NotValidAdressException exception = new NotValidAdressException(errorMessage);
assertEquals(errorMessage, exception.getMessage());
}
@Test
@DisplayName("Exception should be properly thrown and caught")
void testExceptionCanBeThrownAndCaught() {
String errorMessage = "Required field is missing";
Exception exception = assertThrows(NotValidAdressException.class, () -> {
throw new NotValidAdressException(errorMessage);
});
assertEquals(errorMessage, exception.getMessage());
}
@Test
@DisplayName("Exception should be catchable as a general Exception")
void testExceptionInheritance() {
String errorMessage = "Invalid Adresse ";
try {
throw new NotValidAdressException(errorMessage);
} catch (Exception e) {
assertEquals(NotValidAdressException.class, e.getClass());
assertEquals(errorMessage, e.getMessage());
}
}
}
@@ -0,0 +1,61 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.valid;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.NotValidCommandeException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class NotValidCommandeExceptionTest {
@Test
@DisplayName("Exception should be created with the provided message")
void testExceptionCreation() {
String errorMessage = "Commande is not valid";
NotValidCommandeException exception = new NotValidCommandeException(errorMessage);
assertEquals(errorMessage, exception.getMessage());
}
@ParameterizedTest
@ValueSource(strings = {
"Mode Paiement is not valide",
"List ligne commande is not valide"
})
@DisplayName("Exception should handle different validation messages")
void testExceptionWithDifferentMessages(String errorMessage) {
NotValidCommandeException exception = new NotValidCommandeException(errorMessage);
assertEquals(errorMessage, exception.getMessage());
}
@Test
@DisplayName("Exception should be properly thrown and caught")
void testExceptionCanBeThrownAndCaught() {
String errorMessage = "Required field is missing";
Exception exception = assertThrows(NotValidCommandeException.class, () -> {
throw new NotValidCommandeException(errorMessage);
});
assertEquals(errorMessage, exception.getMessage());
}
@Test
@DisplayName("Exception should be catchable as a general Exception")
void testExceptionInheritance() {
String errorMessage = "Invalid Commande ";
try {
throw new NotValidCommandeException(errorMessage);
} catch (Exception e) {
assertEquals(NotValidCommandeException.class, e.getClass());
assertEquals(errorMessage, e.getMessage());
}
}
}
@@ -0,0 +1,47 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.valid;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.exception.NotValidLigneCommandeException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class NotValidLigneCommandeExceptionTest {
@Test
@DisplayName("Exception should handle different validation messages")
void testExceptionCreation() {
String errorMessage = "Ligne commande is not valide";
NotValidLigneCommandeException exception = new NotValidLigneCommandeException(errorMessage);
assertEquals(errorMessage, exception.getMessage());
}
@Test
@DisplayName("Exception should be properly thrown and caught")
void testExceptionCanBeThrownAndCaught() {
String errorMessage = "Required field is missing";
Exception exception = assertThrows(NotValidLigneCommandeException.class, () -> {
throw new NotValidLigneCommandeException(errorMessage);
});
assertEquals(errorMessage, exception.getMessage());
}
@Test
@DisplayName("Exception should be catchable as a general Exception")
void testExceptionInheritance() {
String errorMessage = "Invalid Commande ";
try {
throw new NotValidLigneCommandeException(errorMessage);
} catch (Exception e) {
assertEquals(NotValidLigneCommandeException.class, e.getClass());
assertEquals(errorMessage, e.getMessage());
}
}
}
@@ -0,0 +1,349 @@
package fr.iut_fbleau.but3.dev62.mylibrary.commande.repository;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.LigneCommandeInfo;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.ModePaiement;
import fr.iut_fbleau.but3.dev62.mylibrary.commande.entity.Commande;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*;
public class CommandeRepositoryTest {
private CommandeRepository repository;
private Commande commandeN1;
private Commande commandeN2;
private Commande commandeN3;
@BeforeEach
void setUp() {
repository = new CommandeRepository();
UUID clientId = UUID.randomUUID();
List<LigneCommandeInfo> lignesCommande = new ArrayList<>();
LigneCommandeInfo commande1 = new LigneCommandeInfo(12);
LigneCommandeInfo commande2 = new LigneCommandeInfo(13);
lignesCommande.add(commande1);
lignesCommande.add(commande2);
String rue = "rue du chien";
String ville = "LKa Rochette";
String codePostal = "7700";
String pays = "France";
String modePayement = ModePaiement.CB.name();
commandeN1 = Commande.builder()
.clientId(clientId)
.lignesCommande(lignesCommande)
.rue(rue)
.ville(ville)
.codePostal(codePostal)
.pays(pays)
.modePaiement(modePayement)
.build();
commandeN1.setRandomUUIDCommande();
List<LigneCommandeInfo> lignesCommande2 = new ArrayList<>();
LigneCommandeInfo commande3 = new LigneCommandeInfo(43);
LigneCommandeInfo commande4 = new LigneCommandeInfo(1);
lignesCommande2.add(commande3);
lignesCommande2.add(commande4);
commandeN2 = Commande.builder()
.clientId(clientId)
.lignesCommande(lignesCommande2)
.rue(rue)
.ville(ville)
.codePostal(codePostal)
.pays(pays)
.modePaiement(modePayement)
.build();
commandeN2.setRandomUUIDCommande();
List<LigneCommandeInfo> lignesCommande3 = new ArrayList<>();
LigneCommandeInfo commande6 = new LigneCommandeInfo(12);
LigneCommandeInfo commande7 = new LigneCommandeInfo(13);
lignesCommande3.add(commande6);
lignesCommande3.add(commande7);
String rue2 = "rue du chevre chaud ";
String ville2 = "jsp";
String codePostal2 = "77";
String pays2 = "Lune ";
String modePayement2 = ModePaiement.PAYPAL.name();
commandeN3 = Commande.builder()
.lignesCommande(lignesCommande3)
.rue(rue2)
.ville(ville2)
.codePostal(codePostal2)
.pays(pays2)
.modePaiement(modePayement2)
.build();
commandeN3.setRandomUUID();
commandeN3.setRandomUUIDCommande();
}
@Test
@DisplayName("New repository should be empty")
void testNewRepositoryIsEmpty() {
List<Commande> commande = repository.findAll();
assertTrue(commande.isEmpty());
assertEquals(0, commande.size());
}
@Nested
@DisplayName("Save operations")
class SaveOperations {
@Test
@DisplayName("Save should add a new comande")
void testSaveNewCommande() {
Commande savedCommande = repository.save(commandeN1);
assertEquals(1, repository.findAll().size());
assertEquals(commandeN1.getCommandeId(), savedCommande.getCommandeId());
assertEquals(commandeN1.getClientId(), savedCommande.getClientId());
}
@Test
@DisplayName("Save should update existing commande with same ID")
void testSaveUpdatesExistingCommande() {
repository.save(commandeN1);
List<LigneCommandeInfo> lignesCommande2 = new ArrayList<>();
LigneCommandeInfo commande3 = new LigneCommandeInfo(43);
LigneCommandeInfo commande4 = new LigneCommandeInfo(1);
lignesCommande2.add(commande3);
lignesCommande2.add(commande4);
UUID id = commandeN1.getCommandeId();
Commande updatedCommande = Commande.builder()
.commandeId(id)
.lignesCommande(lignesCommande2)
.rue("rue")
.ville("moi")
.codePostal("1")
.pays("Russie")
.modePaiement(ModePaiement.POINTS_FIDELITE.name())
.build();
Commande savedCommande = repository.save(updatedCommande);
assertEquals(1, repository.findAll().size());
assertEquals(id, savedCommande.getCommandeId());
assertEquals("rue", savedCommande.getRue());
assertEquals("moi", savedCommande.getVille());
assertEquals("1", savedCommande.getCodePostal());
assertEquals("Russie", savedCommande.getPays());
assertEquals(ModePaiement.POINTS_FIDELITE.name(), savedCommande.getModePaiement());
}
@Test
@DisplayName("Save multiple customers should add all of them")
void testSaveMultipleCommande() {
repository.save(commandeN1);
repository.save(commandeN2);
List<Commande> commande = repository.findAll();
assertEquals(2, commande.size());
assertTrue(commande.contains(commandeN1));
assertTrue(commande.contains(commandeN2));
}
}
@Nested
@DisplayName("Find operations")
class FindOperations {
@BeforeEach
void setUpCommande() {
repository.save(commandeN1);
repository.save(commandeN2);
}
@Test
@DisplayName("FindAll should return all commande")
void testFindAll() {
List<Commande> commande = repository.findAll();
assertEquals(2, commande.size());
assertTrue(commande.contains(commandeN1));
assertTrue(commande.contains(commandeN2));
}
@Test
@DisplayName("FindById should return commande with matching ID")
void testFindById() {
Optional<Commande> foundCommande = repository.findById(commandeN1.getCommandeId());
assertTrue(foundCommande.isPresent());
assertEquals(commandeN1.getCommandeId(), foundCommande.get().getCommandeId());
assertEquals(commandeN1.getClientId(), foundCommande.get().getClientId());
}
@Test
void testFindByIdNotFound(){
UUID nonExistentId = UUID.randomUUID();
Optional<Commande> foundCommande = repository.findById(nonExistentId);
assertTrue(foundCommande.isEmpty());
}
@Test
void testExistsByIdExists(){
boolean exists = repository.existsById(commandeN1.getCommandeId());
assertTrue(exists);
}
@Test
void testExistsByIdNotExists(){
UUID nonExistentId = UUID.randomUUID();
boolean exists = repository.existsById(nonExistentId);
assertFalse(exists);
}
}
@Nested
@DisplayName("Delete operations")
class DeleteOperations {
@BeforeEach
void setUpCustomers() {
repository.save(commandeN1);
repository.save(commandeN2);
repository.save(commandeN3);
}
@Test
@DisplayName("Delete should remove the specified customer")
void testDelete() {
repository.delete(commandeN1);
List<Commande> commande = repository.findAll();
assertEquals(2, commande.size());
assertFalse(commande.contains(commandeN1));
assertTrue(commande.contains(commandeN2));
assertTrue(commande.contains(commandeN3));
}
@Test
@DisplayName("DeleteAll should remove all customers")
void testDeleteAll() {
repository.deleteAll();
List<Commande> commande = repository.findAll();
assertTrue(commande.isEmpty());
assertEquals(0, commande.size());
}
@Test
@DisplayName("Delete should not throw exception when customer doesn't exist")
void testDeleteNonExistentCustomer() {
List<LigneCommandeInfo> lignesCommande = new ArrayList<>();
LigneCommandeInfo commande1 = new LigneCommandeInfo(321);
LigneCommandeInfo commande2 = new LigneCommandeInfo(3);
lignesCommande.add(commande1);
lignesCommande.add(commande2);
Commande nonExistentCommande = Commande.builder()
.lignesCommande(lignesCommande)
.rue("non")
.ville("non")
.codePostal("Existent")
.pays("0000")
.modePaiement(ModePaiement.PAYPAL.name())
.build();
nonExistentCommande.setRandomUUIDCommande();
assertDoesNotThrow(() -> repository.delete(nonExistentCommande));
assertEquals(3, repository.findAll().size());
}
@Test
void TestDeleteAllCommandeByCustomerID() {
System.out.println(commandeN1.getClientId());
System.out.println(commandeN2.getClientId());
System.out.println(commandeN3.getClientId());
repository.deleteById(commandeN1.getClientId());
List<Commande> commande = repository.findAll();
assertEquals(1, commande.size());
assertFalse(commande.contains(commandeN1));
assertFalse(commande.contains(commandeN2));
assertTrue(commande.contains(commandeN3));
}
@Test
void TestDeleteAllCommandeByNonExistentCustomerID() {
List<LigneCommandeInfo> lignesCommande = new ArrayList<>();
LigneCommandeInfo commande1 = new LigneCommandeInfo(321);
LigneCommandeInfo commande2 = new LigneCommandeInfo(3);
lignesCommande.add(commande1);
lignesCommande.add(commande2);
Commande nonExistentCommande = Commande.builder()
.lignesCommande(lignesCommande)
.rue("non")
.ville("non")
.codePostal("Existent")
.pays("0000")
.modePaiement(ModePaiement.PAYPAL.name())
.build();
nonExistentCommande.setRandomUUIDCommande();
repository.deleteById(nonExistentCommande.getClientId());
assertDoesNotThrow(() -> repository.findAll());
assertEquals(3, repository.findAll().size());
}
}
}

Some files were not shown because too many files have changed in this diff Show More