18 Commits

Author SHA1 Message Date
876d092fd4 fonction retourLivres créé 2025-10-03 11:28:21 +02:00
7970ca8df6 tests unitaires réalisés 2025-10-03 10:21:45 +02:00
d0db3d84a3 fusions Morgann, Medhi 2025-10-03 10:09:40 +02:00
6e988ca75a Merge pull request 'dev.pomika' (#8) from dev.pomika into developpement
Reviewed-on: #8
2025-10-03 09:32:28 +02:00
906f075a95 Merge branch 'developpement' into dev.pomika 2025-10-03 09:32:14 +02:00
09cf3836c2 longueur titre : tests opérationnels 2025-10-03 09:22:44 +02:00
c762aac862 fusion avec Salomé, Steve et Emile pour les tests unitaires 2025-10-03 09:21:27 +02:00
a606a72476 Merge branch 'MalcuitEmile' into developpement
# Conflicts:
#	src/test/java/com/mycompany/bibliotheque/LivreValideTest.java
2025-10-03 08:43:45 +02:00
9f0f1ae00e Merge branch 'developpement' of https://gitea.lyc-lecastel.fr/delphine.thevenot/2026TestsBibliotheque into MalcuitEmile 2025-10-02 22:20:24 +02:00
1f44c6ee69 rajout méthode testIsContenuTitreValid à compléter 2025-10-02 21:50:36 +02:00
3f63db1a92 Merge branch 'MalcuitEmile' into developpement
Ajout partie Emile isValidIsbn
doit avoir 13 chiffres (pas de lettres, pas de caractères spéciaux)
2025-10-02 21:43:56 +02:00
19d2e618c3 test livre ok 2025-09-26 11:23:46 +02:00
emile.malcuit
9593ca5fab test unitaire 13 carractère isbn 2025-09-26 11:20:29 +02:00
6e8f63e2c0 Actualiser .gitignore 2025-09-26 10:36:52 +02:00
emile.malcuit
a7b45071cc Init branch emile 2025-09-26 10:19:30 +02:00
sio
22bce1d53b màj javadoc 2025-09-26 09:45:12 +02:00
6ec5d152eb Merge pull request 'màj LivreValidTest.java' (#3) from Prof into developpement
Reviewed-on: #3
2025-09-26 08:58:04 +02:00
sio
f1571ced27 màj LivreValidTest.java 2025-09-26 08:56:57 +02:00
12 changed files with 265 additions and 84 deletions

4
.gitignore vendored
View File

@@ -1 +1,5 @@
/target/
<<<<<<< HEAD
=======
*.xml
>>>>>>> 6e8f63e2c0b4f89a6f46070511e8ce4223af4bb7

View File

@@ -0,0 +1,100 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.bibliotheque.Controle;
import com.mycompany.bibliotheque.Metier.Livre;
import com.mycompany.bibliotheque.Metier.Utilisateur;
import java.util.Scanner;
/**
* Classe de contrôle de la classe Livre
* @author dthev
*/
public class LivreValide {
// 1. ISBN : exactement 13 chiffres
public static boolean isValidIsbn(String isbn) {
// TODO Emile: implémenter la validation
boolean valide = true;
if(isbn.length() == 13){
int i = 0;
while (i < 13 && valide) {
if(!Character.isDigit(isbn.charAt(i))){
valide = false;
}else{
i++;
}
}
}else{
valide = false;
}
return valide;
}
// 2. Titre : pas de balises HTML/JS (<script>, <img>, etc.)
public static boolean isValidTitre(String Titre) {
// TODO Salomon: implémenter la validation
boolean test = true;
int i = 0;
while (i < Titre.length() && test) {
if(Titre.charAt(i) == '<' || Titre.charAt(i) == '>'){
test = false;
}else{
i++;
}
}
return test;
}
// 3. Auteur : non vide et pas de chiffres ou caractères spéciaux
public static boolean isValidAuteur(String auteur) {
//verification que auteur n'est pas vide ou null
if (auteur == null || auteur.isBlank()) {
return false;
}
//ajout d'un pattern pour avoir uniquement des minuscules/majuscules
String pattern = "^[a-zA-Z]+$";
//verification boolean que le nom d'auteur corresponde au patterne
return auteur.matches(pattern);
}
// 4. Titre : longueur maximale 200 caractères
public static boolean isLongueurTitreValid(String titre) {
// TODO Morgann: implémenter la validation
boolean valide = false;
if(titre.length()<=200 && titre != "" && titre != null){
valide = true;
}
return valide;
}
// 5. Titre : non null et au moins 2 caractères
public static boolean isContenuTitreValide(String titre) {
// TODO Steve: implémenter la validation
if (titre == null) {
return false;
}
boolean contenuValide = titre.matches(".*[a-zA-Z].*[a-zA-Z].*");
return contenuValide;
}
public static boolean retourLivre(Utilisateur user){
Scanner sc = new Scanner(System.in);
int i=0;
for(Livre unLivre:user.getEmprunts()){
i++;
System.out.println(i+". "+unLivre.getTitre());
}
System.out.print("Merci de faire votre choix : ");
int choix = sc.nextInt();
Livre leLivre = user.getEmprunts().get(choix-1);
leLivre.setEmprunte(false);
user.getEmprunts().remove(leLivre);
return leLivre.isEmprunte();
}
}

View File

@@ -1,41 +0,0 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.bibliotheque.Contrôle;
/**
* Classe de contrôle de la classe Livre
* @author dthev
*/
public class LivreValide {
// 1. ISBN : exactement 13 chiffres
public static boolean isValidIsbn(String isbn) {
// TODO: implémenter la validation
return false;
}
// 2. Titre : pas de balises HTML/JS (<script>, <img>, etc.)
public static boolean isValidTitre(String Titre) {
// TODO: implémenter la validation
return false;
}
// 3. Auteur : non vide et pas de chiffres ou caractères spéciaux
public static boolean isValidAuteur(String auteur) {
// TODO: implémenter la validation
return false;
}
// 4. Titre : longueur maximale 200 caractères
public static boolean isLongueurTitreValid(String titre) {
// TODO: implémenter la validation
return false;
}
// 5. Titre : non null et au moins 2 caractères
public static boolean isContenuTitreValide(String titre) {
// TODO: implémenter la validation
return false;
}
}

View File

@@ -10,10 +10,10 @@ package com.mycompany.bibliotheque;
*/
import com.mycompany.bibliotheque.Métier.Bibliotheque;
import com.mycompany.bibliotheque.Métier.Emprunt;
import com.mycompany.bibliotheque.Métier.Utilisateur;
import com.mycompany.bibliotheque.Métier.Livre;
import com.mycompany.bibliotheque.Metier.Bibliotheque;
import com.mycompany.bibliotheque.Metier.Emprunt;
import com.mycompany.bibliotheque.Metier.Utilisateur;
import com.mycompany.bibliotheque.Metier.Livre;
import java.util.Scanner;
public class GestionBibliotheque {

View File

@@ -2,7 +2,7 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.bibliotheque.Métier;
package com.mycompany.bibliotheque.Metier;
import java.util.ArrayList;
import java.util.List;

View File

@@ -2,10 +2,10 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.bibliotheque.Métier;
package com.mycompany.bibliotheque.Metier;
import com.mycompany.bibliotheque.Métier.Utilisateur;
import com.mycompany.bibliotheque.Métier.Livre;
import com.mycompany.bibliotheque.Metier.Utilisateur;
import com.mycompany.bibliotheque.Metier.Livre;
/**
*

View File

@@ -2,7 +2,7 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.bibliotheque.Métier;
package com.mycompany.bibliotheque.Metier;
/**
*

View File

@@ -2,14 +2,14 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.bibliotheque.Métier;
package com.mycompany.bibliotheque.Metier;
/**
*
* @author dthev
*/
import com.mycompany.bibliotheque.Métier.Livre;
import com.mycompany.bibliotheque.Metier.Livre;
import java.util.ArrayList;
import java.util.List;

View File

@@ -4,8 +4,8 @@
*/
package com.mycompany.bibliotheque;
import com.mycompany.bibliotheque.Métier.Bibliotheque;
import com.mycompany.bibliotheque.Métier.Livre;
import com.mycompany.bibliotheque.Metier.Bibliotheque;
import com.mycompany.bibliotheque.Metier.Livre;
import java.util.List;
import org.junit.Before;
import org.junit.Test;

View File

@@ -4,7 +4,7 @@
*/
package com.mycompany.bibliotheque;
import com.mycompany.bibliotheque.Métier.Livre;
import com.mycompany.bibliotheque.Metier.Livre;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -16,7 +16,7 @@ public void testCreationLivre() {
assertNotNull(b);
assertEquals("1984", b.getTitre());
assertEquals("George Orwel", b.getAuteur()); // corrigé
assertEquals("George Orwell", b.getAuteur()); // corrigé
assertEquals("1234567890123", b.getIsbn());
assertFalse(b.isEmprunte()); // si la méthode existe
}

View File

@@ -4,7 +4,7 @@
*/
package com.mycompany.bibliotheque;
import com.mycompany.bibliotheque.Contrôle.LivreValide;
import com.mycompany.bibliotheque.Controle.LivreValide;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -24,58 +24,176 @@ public class LivreValideTest {
/**
* Test of isValidIsbn method, of class LivreValide.
* @author Emile
*/
@Test
public void testIsValidIsbn() {
System.out.println("isValidIsbn");
String isbn = "";
boolean expResult = false;
boolean result = LivreValide.isValidIsbn(isbn);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
//Test 1 : un isbn avec moins de 13 carractères
System.out.println("Test1 : un isbn avec moins de 13 carractères");
String isbn1 = "1234568912";
boolean expResult1 = false;
boolean result1 = LivreValide.isValidIsbn(isbn1);
assertEquals("Le nombre de carractère est censé est trop petit",expResult1, result1);
assertFalse("Trop petit",LivreValide.isValidIsbn(isbn1));
System.out.println("Le test1 est validé");
System.out.println("--------------------------------------------------");
System.out.println(" ");
//Test2 : lettre dans l'isbn
System.out.println("Test2 : lettre dans l'isbn");
String isbn2 = "123456789ABC2";
boolean expResult2 = false;
boolean result2 = LivreValide.isValidIsbn(isbn2);
assertEquals("Les alphas ne sont pas autorisés", expResult2, result2);
System.out.println("Le test2 est validé");
System.out.println("--------------------------------------------------");
System.out.println(" ");
//Test3 : mauvais nombre de carratère 15
System.out.println("Test3: isbn comportant plus de 13 chiffres");
String isbn3 = "1234568912123568";
boolean expResult3 = false;
boolean result3 = LivreValide.isValidIsbn(isbn3);
assertEquals("Le nombre de carractère est censé est trop grand",expResult3, result3);
System.out.println("Le test3 est validé");
System.out.println("--------------------------------------------------");
System.out.println(" ");
//Test4 : Un isbn valide
System.out.println("Test4: Un isbn valide");
String isbn4 = "1234568912126";
boolean expResult4 = true;
boolean result4 = LivreValide.isValidIsbn(isbn4);
assertEquals("L'isbn est censé être valide",expResult4, result4);
System.out.println("Le test4 est validé");
System.out.println("--------------------------------------------------");
System.out.println(" ");
}
/**
* Test of isValidTitre method, of class LivreValide.
* @author Salomé/Emile
*/
@Test
public void testIsValidTitre() {
System.out.println("isValidTitre");
String Titre = "";
boolean expResult = false;
boolean result = LivreValide.isValidTitre(Titre);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
System.out.println("Test1 : un titre comportant un '<'");
String Titre1 = "La chat<perché";
boolean expResult1 = false;
boolean result1 = LivreValide.isValidTitre(Titre1);
assertEquals("Le chevron < n'est pas censé etre accepté",expResult1, result1);
System.out.println("Le test1 est validé");
System.out.println("--------------------------------------------------");
System.out.println(" ");
System.out.println("Test2 : un titre comportant un '>'");
String Titre2 = "La chat >perché";
boolean expResult2 = false;
boolean result2 = LivreValide.isValidTitre(Titre2);
assertEquals("Le chevron > n'est pas censé etre accepté",expResult2, result2);
System.out.println("Le test2 est validé");
System.out.println("--------------------------------------------------");
System.out.println(" ");
System.out.println("Test3 : un titre valide");
String Titre3 = "La chat perché";
boolean expResult3 = true;
boolean result3 = LivreValide.isValidTitre(Titre3);
assertEquals("Ce titre est cencé être valide",expResult3, result3);
System.out.println("Le test3 est validé");
System.out.println("--------------------------------------------------");
System.out.println(" ");
}
/**
* Test of isValidAuteur method, of class LivreValide.
* @author Medhi/Steve
*/
@Test
public void testIsValidAuteur() {
System.out.println("isValidAuteur");
String auteur = "";
boolean expResult = false;
boolean result = LivreValide.isValidAuteur(auteur);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
//Verification Bonne
String auteurTrue = "George";
boolean expResult = true;
boolean result = LivreValide.isValidAuteur(auteurTrue);
assertEquals("Cas d'utilisation prévu",expResult, result);
//Verification avec un nombre
String auteurFalse1 = "George4";
boolean expResult1 = false;
boolean result1 = LivreValide.isValidAuteur(auteurFalse1);
assertEquals("Non valide car un nombre est présent", expResult1,result1);
//Verification avec des caractères spéciaux
String auteurFalse2 = "George_";
boolean expResult2 = false;
boolean result2 = LivreValide.isValidAuteur(auteurFalse2);
assertEquals("Non valide car des caractères spéciaux sont présent", expResult2,result2);
}
/**
* Test of isLongueurTitreValid method, of class LivreValide.
* @author Morgann
*/
@Test
public void testIsLongueurTitreValid() {
System.out.println("isLongueurTitreValid");
String titre = "";
boolean expResult = false;
boolean result = LivreValide.isLongueurTitreValid(titre);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
//test 1 : aucune valeur saisie
System.out.println("Test avec aucune valeur saisie");
String titre1 = "";
boolean expResult1 = false;
boolean result1 = LivreValide.isLongueurTitreValid(titre1);
assertEquals(expResult1, result1);
System.out.println("Titre invalide. Aucune valeur n'a été saisie\n");
//test 2 : titre inférieur à 200
System.out.println("Test avec valeur saisie OK");
String titre2 = "Hadal Blacksite bestiary";
boolean expResult2 = true;
boolean result2 = LivreValide.isLongueurTitreValid(titre2);
assertEquals(expResult2, result2);
System.out.println("Titre valide. Le titre a moins de 200 caractères\n");
System.out.println("Test avec un titre avec plus de 200 caractères");
String titre3 = "YOU !! You could've had everything you ever wanted... Everything I ever wanted... And you still went out of your way to take everything I had left in the process. You entitled brat. You expect me to sit idly by and keep smiling, As if nothing ever happened? Oh, I'm smiling alright... GRINNING ear to ear. Don't even start with that 'following orders' schlock. You knew what you were doing all too well. Sure took your sweet time. Enjoyed every last second of it? Good. *Chuckles* EXCELLENT, even! I'll merely return the favor. And you bet, I'll be enjoying, every last moment, of THIS!!! THE BEST PART!? I get to do this, over, and over, again. You'll come back, I'll know, and I'll be waiting... You have no one to blame but yourself. You're in a hell of your own making... And you're NEVER GETTING OUT!!! *grrgh* WHAT!!! WHAT IS IT THIS TIME!?!?";
boolean expResult3 = false;
boolean result3 = LivreValide.isLongueurTitreValid(titre3);
assertEquals(expResult3, result3);
System.out.println("Titre invalide. Titre trop long\n");
}
/**
* Test of isTitreValid method, of class LivreValide.
* @author Steve
*/
@Test
public void testIsContenuTitreValide() {
System.out.println("isTitreValid");
String titre = "";
assertFalse("Le titre ne doit pas être vide !", LivreValide.isContenuTitreValide(titre));
titre = null;
assertFalse("Le titre ne peut pas être nul !", LivreValide.isContenuTitreValide(titre));
titre = "Ti";
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "T";
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "1234";
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "Ti2";
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "*$!";
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
titre = "Ti!";
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
}
}

View File

@@ -4,8 +4,8 @@
*/
package com.mycompany.bibliotheque;
import com.mycompany.bibliotheque.Métier.Utilisateur;
import com.mycompany.bibliotheque.Métier.Livre;
import com.mycompany.bibliotheque.Metier.Utilisateur;
import com.mycompany.bibliotheque.Metier.Livre;
import java.util.List;
import org.junit.Before;
import org.junit.Test;