Steve - Test d'unicité de l'ISBN #14
@@ -2,16 +2,16 @@
|
|||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* 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
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque.Contrôle;
|
package com.mycompany.bibliotheque.Controle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe de contrôle de la classe Livre
|
* Classe de contrôle de la classe Livre
|
||||||
* @author dthev
|
* @author dthev
|
||||||
*/
|
*/
|
||||||
public class LivreValide {
|
public class LivreValide {
|
||||||
// 1. ISBN : exactement 13 chiffres
|
// 1. ISBN : exactement 13 chiffres
|
||||||
public static boolean isValidIsbn(String isbn) {
|
public static boolean isValidIsbn(String isbn) {
|
||||||
// TODO Emile: implémenter la validation
|
// TODO Emile: implémenter la validation
|
||||||
|
|
||||||
boolean valide = true;
|
boolean valide = true;
|
||||||
if(isbn.length() == 13){
|
if(isbn.length() == 13){
|
||||||
@@ -45,21 +45,31 @@ public class LivreValide {
|
|||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Auteur : non vide et pas de chiffres ou caractères spéciaux
|
// 3. Auteur : non vide et pas de chiffres ou caractères spéciaux
|
||||||
public static boolean isValidAuteur(String auteur) {
|
public static boolean isValidAuteur(String auteur) {
|
||||||
// TODO: implémenter la validation
|
//verification que auteur n'est pas vide ou null
|
||||||
return false;
|
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
|
// 4. Titre : longueur maximale 200 caractères
|
||||||
public static boolean isLongueurTitreValid(String titre) {
|
public static boolean isLongueurTitreValid(String titre) {
|
||||||
// TODO Morgann: implémenter la validation
|
// TODO Morgann: implémenter la validation
|
||||||
return false;
|
boolean valide = false;
|
||||||
|
if(titre.length()<=200 && titre != "" && titre != null){
|
||||||
|
valide = true;
|
||||||
|
}
|
||||||
|
return valide;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Titre : non null et au moins 2 caractères
|
// 5. Titre : non null et au moins 2 caractères
|
||||||
public static boolean isContenuTitreValide(String titre) {
|
public static boolean isContenuTitreValide(String titre) {
|
||||||
// TODO Steve: implémenter la validation
|
// TODO Steve: implémenter la validation
|
||||||
if (titre == null) {
|
if (titre == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@@ -10,10 +10,11 @@ package com.mycompany.bibliotheque;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Bibliotheque;
|
import com.mycompany.bibliotheque.Metier.Utilisateur;
|
||||||
import com.mycompany.bibliotheque.Métier.Emprunt;
|
import com.mycompany.bibliotheque.Metier.Bibliotheque;
|
||||||
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
import com.mycompany.bibliotheque.Metier.Emprunt;
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
import com.mycompany.bibliotheque.Metier.Utilisateur;
|
||||||
|
import com.mycompany.bibliotheque.Metier.Livre;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class GestionBibliotheque {
|
public class GestionBibliotheque {
|
||||||
|
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.Metier;
|
||||||
|
|
||||||
|
import com.mycompany.bibliotheque.Controle.LivreValide;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe métier
|
||||||
|
* @author dthev
|
||||||
|
*/
|
||||||
|
public class Bibliotheque {
|
||||||
|
private List<Livre> lesLivres = new ArrayList<>();
|
||||||
|
|
||||||
|
// 5. ISBN doit être unique
|
||||||
|
public boolean addLivre(Livre b) {
|
||||||
|
//ajoute b si valide et si n'existe pas - à écrire
|
||||||
|
String issues = "";
|
||||||
|
if (!LivreValide.isValidIsbn(b.getIsbn())) issues += "1 ";
|
||||||
|
if (!LivreValide.isValidTitre(b.getTitre())) issues += "2 ";
|
||||||
|
if (!LivreValide.isValidAuteur(b.getAuteur())) issues += "3 ";
|
||||||
|
if (!LivreValide.isLongueurTitreValid(b.getTitre())) issues += "4 ";
|
||||||
|
if (!LivreValide.isContenuTitreValide(b.getTitre())) issues += "5";
|
||||||
|
|
||||||
|
System.out.println(issues);
|
||||||
|
|
||||||
|
if (issues.length() < 1) {
|
||||||
|
System.out.println("valide");
|
||||||
|
for (Livre livre : this.getLesLivres()) {
|
||||||
|
if (livre.getIsbn().equals(b.getIsbn())) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lesLivres.add(b);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Livre> getLesLivres() {
|
||||||
|
return lesLivres;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLesLivres(List<Livre> lesLivres) {
|
||||||
|
this.lesLivres = lesLivres;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -2,10 +2,10 @@
|
|||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* 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
|
* 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.Metier.Utilisateur;
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
import com.mycompany.bibliotheque.Metier.Livre;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@@ -2,7 +2,7 @@
|
|||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* 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
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque.Métier;
|
package com.mycompany.bibliotheque.Metier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@@ -2,14 +2,14 @@
|
|||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* 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
|
* 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
|
* @author dthev
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
import com.mycompany.bibliotheque.Metier.Livre;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -32,6 +32,6 @@ public class Utilisateur {
|
|||||||
|
|
||||||
// TODO: ajouter un emprunt si l'utilisateur a moins de 3 livres
|
// TODO: ajouter un emprunt si l'utilisateur a moins de 3 livres
|
||||||
public boolean emprunterLivre(Livre livre) {
|
public boolean emprunterLivre(Livre livre) {
|
||||||
return false; // à compléter
|
return false; // à compléter
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,33 +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.Métier;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Classe métier
|
|
||||||
* @author dthev
|
|
||||||
*/
|
|
||||||
public class Bibliotheque {
|
|
||||||
private List<Livre> lesLivres = new ArrayList<>();
|
|
||||||
|
|
||||||
// 5. ISBN doit être unique
|
|
||||||
public boolean addLivre(Livre b) {
|
|
||||||
//ajoute b si valide et si n'existe pas - à écrire
|
|
||||||
lesLivres.add(b);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Livre> getLesLivres() {
|
|
||||||
return lesLivres;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLesLivres(List<Livre> lesLivres) {
|
|
||||||
this.lesLivres = lesLivres;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -4,8 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Bibliotheque;
|
import com.mycompany.bibliotheque.Metier.Bibliotheque;
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
import com.mycompany.bibliotheque.Metier.Livre;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -30,13 +30,49 @@ public class BibliothequeTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testAddLivre() {
|
public void testAddLivre() {
|
||||||
System.out.println("addLivre");
|
System.out.println("addLivre");
|
||||||
Livre b = null;
|
|
||||||
Bibliotheque instance = new Bibliotheque();
|
Bibliotheque instance = new Bibliotheque();
|
||||||
boolean expResult = false;
|
|
||||||
boolean result = instance.addLivre(b);
|
// Ajout d'un livre avec ISBN invalide
|
||||||
assertEquals(expResult, result);
|
Livre livre = new Livre("Naruto", "Masashi Kishimoto", "1234ABCD567", false);
|
||||||
// TODO review the generated test code and remove the default call to fail.
|
boolean ajoutLivre = instance.addLivre(livre);
|
||||||
fail("The test case is a prototype.");
|
System.out.println("Refus de l'ISBN invalide");
|
||||||
|
assertFalse("L'ISBN du livre n'est pas censé être valide avec lettres !", ajoutLivre);
|
||||||
|
|
||||||
|
// Ajout d'un livre avec titre invalide
|
||||||
|
livre = new Livre("<script>Dragon Ball</script>", "Akira Toriyama", "8762709652385", false);
|
||||||
|
ajoutLivre = instance.addLivre(livre);
|
||||||
|
System.out.println("Refus de titre invalide");
|
||||||
|
assertFalse("Le titre du livre n'est pas censé être valide avec des balises !", ajoutLivre);
|
||||||
|
|
||||||
|
// Ajout d'un livre avec auteur invalide
|
||||||
|
livre = new Livre("Dr. STONE", "Bo1ch1", "8762207682385", false);
|
||||||
|
ajoutLivre = instance.addLivre(livre);
|
||||||
|
System.out.println("Refus d'auteur invalide");
|
||||||
|
assertFalse("L'auteur du livre n'est pas censé être valide avec des caractères non alphabétiques !", ajoutLivre);
|
||||||
|
|
||||||
|
// Ajout d'un livre avec longueur de titre invalide
|
||||||
|
livre = new Livre("Dandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadandadan", "Yukinobu Tatsu", "1702203672985", false);
|
||||||
|
ajoutLivre = instance.addLivre(livre);
|
||||||
|
System.out.println("Refus de longueur de titre invalide");
|
||||||
|
assertFalse("Le titre n'est pas censé être valide avec une longueur excédant les 200 caractères !", ajoutLivre);
|
||||||
|
|
||||||
|
// Ajout d'un livre avec contenu de titre invalide
|
||||||
|
livre = new Livre("007", "Steve Maingana", "3712503622788", false);
|
||||||
|
ajoutLivre = instance.addLivre(livre);
|
||||||
|
System.out.println("Refus de contenu de titre invalide invalide");
|
||||||
|
assertFalse("Le titre n'est pas censé être valide sans au moins 2 caractères alphabétiques !", ajoutLivre);
|
||||||
|
|
||||||
|
// Premier ajout de livre
|
||||||
|
livre = new Livre("Frieren", "Kanehito Yamada", "6785708652385", false);
|
||||||
|
ajoutLivre = instance.addLivre(livre);
|
||||||
|
System.out.println("Premier ajout d'un même livre");
|
||||||
|
System.out.println(ajoutLivre);
|
||||||
|
assertTrue("La bibliothèque ne permet pas de doublon !", ajoutLivre);
|
||||||
|
|
||||||
|
// Second ajout du même livre
|
||||||
|
ajoutLivre = instance.addLivre(livre);
|
||||||
|
System.out.println("Refus d'ajout du même livre");
|
||||||
|
assertFalse("La bibliothèque ne permet pas de doublon !", ajoutLivre);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,5 +101,4 @@ public class BibliothequeTest {
|
|||||||
// TODO review the generated test code and remove the default call to fail.
|
// TODO review the generated test code and remove the default call to fail.
|
||||||
fail("The test case is a prototype.");
|
fail("The test case is a prototype.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
import com.mycompany.bibliotheque.Metier.Livre;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@@ -16,8 +16,8 @@ public void testCreationLivre() {
|
|||||||
|
|
||||||
assertNotNull(b);
|
assertNotNull(b);
|
||||||
assertEquals("1984", b.getTitre());
|
assertEquals("1984", b.getTitre());
|
||||||
assertEquals("George Orwel", b.getAuteur()); // corrigé
|
assertEquals("George Orwel", b.getAuteur()); // corrigé
|
||||||
assertEquals("1234567890123", b.getIsbn());
|
assertEquals("1234567890123", b.getIsbn());
|
||||||
assertFalse(b.isEmprunte()); // si la méthode existe
|
assertFalse(b.isEmprunte()); // si la méthode existe
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Contrôle.LivreValide;
|
import com.mycompany.bibliotheque.Controle.LivreValide;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@@ -31,14 +31,14 @@ public class LivreValideTest {
|
|||||||
System.out.println("isValidIsbn");
|
System.out.println("isValidIsbn");
|
||||||
|
|
||||||
|
|
||||||
//Test 1 : un isbn avec moins de 13 carractères
|
//Test 1 : un isbn avec moins de 13 carractères
|
||||||
System.out.println("Test1 : un isbn avec moins de 13 carractères");
|
System.out.println("Test1 : un isbn avec moins de 13 carractères");
|
||||||
String isbn1 = "1234568912";
|
String isbn1 = "1234568912";
|
||||||
boolean expResult1 = false;
|
boolean expResult1 = false;
|
||||||
boolean result1 = LivreValide.isValidIsbn(isbn1);
|
boolean result1 = LivreValide.isValidIsbn(isbn1);
|
||||||
assertEquals("Le nombre de carractère est censé est trop petit",expResult1, result1);
|
assertEquals("Le nombre de carractère est censé est trop petit",expResult1, result1);
|
||||||
assertFalse("Trop petit",LivreValide.isValidIsbn(isbn1));
|
assertFalse("Trop petit",LivreValide.isValidIsbn(isbn1));
|
||||||
System.out.println("Le test1 est validé");
|
System.out.println("Le test1 est validé");
|
||||||
System.out.println("--------------------------------------------------");
|
System.out.println("--------------------------------------------------");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
|
|
||||||
@@ -47,18 +47,18 @@ public class LivreValideTest {
|
|||||||
String isbn2 = "123456789ABC2";
|
String isbn2 = "123456789ABC2";
|
||||||
boolean expResult2 = false;
|
boolean expResult2 = false;
|
||||||
boolean result2 = LivreValide.isValidIsbn(isbn2);
|
boolean result2 = LivreValide.isValidIsbn(isbn2);
|
||||||
assertEquals("Les alphas ne sont pas autorisés", expResult2, result2);
|
assertEquals("Les alphas ne sont pas autorisés", expResult2, result2);
|
||||||
System.out.println("Le test2 est validé");
|
System.out.println("Le test2 est validé");
|
||||||
System.out.println("--------------------------------------------------");
|
System.out.println("--------------------------------------------------");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
|
|
||||||
//Test3 : mauvais nombre de carratère 15
|
//Test3 : mauvais nombre de carratère 15
|
||||||
System.out.println("Test3: isbn comportant plus de 13 chiffres");
|
System.out.println("Test3: isbn comportant plus de 13 chiffres");
|
||||||
String isbn3 = "1234568912123568";
|
String isbn3 = "1234568912123568";
|
||||||
boolean expResult3 = false;
|
boolean expResult3 = false;
|
||||||
boolean result3 = LivreValide.isValidIsbn(isbn3);
|
boolean result3 = LivreValide.isValidIsbn(isbn3);
|
||||||
assertEquals("Le nombre de carractère est censé est trop grand",expResult3, result3);
|
assertEquals("Le nombre de carractère est censé est trop grand",expResult3, result3);
|
||||||
System.out.println("Le test3 est validé");
|
System.out.println("Le test3 est validé");
|
||||||
System.out.println("--------------------------------------------------");
|
System.out.println("--------------------------------------------------");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@ public class LivreValideTest {
|
|||||||
String isbn4 = "1234568912126";
|
String isbn4 = "1234568912126";
|
||||||
boolean expResult4 = true;
|
boolean expResult4 = true;
|
||||||
boolean result4 = LivreValide.isValidIsbn(isbn4);
|
boolean result4 = LivreValide.isValidIsbn(isbn4);
|
||||||
assertEquals("L'isbn est censé être valide",expResult4, result4);
|
assertEquals("L'isbn est censé être valide",expResult4, result4);
|
||||||
System.out.println("Le test4 est validé");
|
System.out.println("Le test4 est validé");
|
||||||
System.out.println("--------------------------------------------------");
|
System.out.println("--------------------------------------------------");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
|
|
||||||
@@ -76,37 +76,37 @@ public class LivreValideTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of isValidTitre method, of class LivreValide.
|
* Test of isValidTitre method, of class LivreValide.
|
||||||
* @author Salomé/Emile
|
* @author Salomé/Emile
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsValidTitre() {
|
public void testIsValidTitre() {
|
||||||
System.out.println("isValidTitre");
|
System.out.println("isValidTitre");
|
||||||
|
|
||||||
System.out.println("Test1 : un titre comportant un '<'");
|
System.out.println("Test1 : un titre comportant un '<'");
|
||||||
String Titre1 = "La chat<perché";
|
String Titre1 = "La chat<perché";
|
||||||
boolean expResult1 = false;
|
boolean expResult1 = false;
|
||||||
boolean result1 = LivreValide.isValidTitre(Titre1);
|
boolean result1 = LivreValide.isValidTitre(Titre1);
|
||||||
assertEquals("Le chevron < n'est pas censé etre accepté",expResult1, result1);
|
assertEquals("Le chevron < n'est pas censé etre accepté",expResult1, result1);
|
||||||
System.out.println("Le test1 est validé");
|
System.out.println("Le test1 est validé");
|
||||||
System.out.println("--------------------------------------------------");
|
System.out.println("--------------------------------------------------");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
|
|
||||||
System.out.println("Test2 : un titre comportant un '>'");
|
System.out.println("Test2 : un titre comportant un '>'");
|
||||||
String Titre2 = "La chat >perché";
|
String Titre2 = "La chat >perché";
|
||||||
boolean expResult2 = false;
|
boolean expResult2 = false;
|
||||||
boolean result2 = LivreValide.isValidTitre(Titre2);
|
boolean result2 = LivreValide.isValidTitre(Titre2);
|
||||||
assertEquals("Le chevron > n'est pas censé etre accepté",expResult2, result2);
|
assertEquals("Le chevron > n'est pas censé etre accepté",expResult2, result2);
|
||||||
System.out.println("Le test2 est validé");
|
System.out.println("Le test2 est validé");
|
||||||
System.out.println("--------------------------------------------------");
|
System.out.println("--------------------------------------------------");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Test3 : un titre valide");
|
System.out.println("Test3 : un titre valide");
|
||||||
String Titre3 = "La chat perché";
|
String Titre3 = "La chat perché";
|
||||||
boolean expResult3 = true;
|
boolean expResult3 = true;
|
||||||
boolean result3 = LivreValide.isValidTitre(Titre3);
|
boolean result3 = LivreValide.isValidTitre(Titre3);
|
||||||
assertEquals("Ce titre est cencé être valide",expResult3, result3);
|
assertEquals("Ce titre est cencé être valide",expResult3, result3);
|
||||||
System.out.println("Le test3 est validé");
|
System.out.println("Le test3 est validé");
|
||||||
System.out.println("--------------------------------------------------");
|
System.out.println("--------------------------------------------------");
|
||||||
System.out.println(" ");
|
System.out.println(" ");
|
||||||
}
|
}
|
||||||
@@ -156,6 +156,7 @@ public class LivreValideTest {
|
|||||||
public void testIsContenuTitreValide() {
|
public void testIsContenuTitreValide() {
|
||||||
System.out.println("isTitreValid");
|
System.out.println("isTitreValid");
|
||||||
String titre = "";
|
String titre = "";
|
||||||
|
System.out.println();
|
||||||
assertFalse("Le titre ne doit pas être vide !", LivreValide.isContenuTitreValide(titre));
|
assertFalse("Le titre ne doit pas être vide !", LivreValide.isContenuTitreValide(titre));
|
||||||
titre = null;
|
titre = null;
|
||||||
assertFalse("Le titre ne peut pas être nul !", LivreValide.isContenuTitreValide(titre));
|
assertFalse("Le titre ne peut pas être nul !", LivreValide.isContenuTitreValide(titre));
|
||||||
|
@@ -4,8 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
import com.mycompany.bibliotheque.Metier.Utilisateur;
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
import com.mycompany.bibliotheque.Metier.Livre;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
Reference in New Issue
Block a user