Compare commits
17 Commits
testNewBib
...
c762aac862
Author | SHA1 | Date | |
---|---|---|---|
c762aac862 | |||
a606a72476 | |||
9f0f1ae00e | |||
1f44c6ee69 | |||
3f63db1a92 | |||
|
9593ca5fab | ||
6e8f63e2c0 | |||
|
a7b45071cc | ||
|
22bce1d53b | ||
6ec5d152eb | |||
|
f1571ced27 | ||
ca3338fe1a | |||
|
0eac6c497d | ||
|
980fc1cc7c | ||
bec1ca9f04 | |||
fd2f9066b7 | |||
d92fa2649e |
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/target/
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
*.xml
|
||||||
|
>>>>>>> 6e8f63e2c0b4f89a6f46070511e8ce4223af4bb7
|
8
pom.xml
8
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.mycompany</groupId>
|
<groupId>com.mycompany</groupId>
|
||||||
<artifactId>GestionBibliotheque</artifactId>
|
<artifactId>bibliotheque</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
<version>4.13.2</version>
|
<version>4.13.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!-- Configuration du build -->
|
<!-- Configuration du build -->
|
||||||
@@ -29,10 +28,9 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.22.2</version>
|
<version>3.1.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<name>GestionBibliotheque</name>
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -9,16 +9,40 @@ package com.mycompany.bibliotheque.Contrôle;
|
|||||||
* @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: implémenter la validation
|
// TODO Emile: implémenter la validation
|
||||||
return false;
|
|
||||||
|
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.)
|
// 2. Titre : pas de balises HTML/JS (<script>, <img>, etc.)
|
||||||
public static boolean isValidTitre(String Titre) {
|
public static boolean isValidTitre(String Titre) {
|
||||||
// TODO: implémenter la validation
|
// TODO Salomon: implémenter la validation
|
||||||
return false;
|
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
|
// 3. Auteur : non vide et pas de chiffres ou caractères spéciaux
|
||||||
@@ -27,9 +51,21 @@ public class LivreValide {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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: implémenter la validation
|
// TODO Morgann: implémenter la validation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.mycompany.bibliotheque;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe principale
|
||||||
|
* @author dthev
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Bibliotheque;
|
import com.mycompany.bibliotheque.Métier.Bibliotheque;
|
||||||
import com.mycompany.bibliotheque.Métier.Emprunt;
|
import com.mycompany.bibliotheque.Métier.Emprunt;
|
||||||
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
import com.mycompany.bibliotheque.Métier.Livre;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author dthev
|
|
||||||
*/
|
|
||||||
public class GestionBibliotheque {
|
public class GestionBibliotheque {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
@@ -25,10 +27,10 @@ public class GestionBibliotheque {
|
|||||||
System.out.println("Bienvenue dans la bibliothèque !");
|
System.out.println("Bienvenue dans la bibliothèque !");
|
||||||
while (choix!=4){
|
while (choix!=4){
|
||||||
System.out.println("1. Afficher un livre");
|
System.out.println("1. Afficher un livre");
|
||||||
System.out.println("3. Ajouter un livre");
|
System.out.println("2. Ajouter un livre");
|
||||||
System.out.println("3. Afficher les livres");
|
System.out.println("3. Afficher les livres");
|
||||||
System.out.println("4. Quitter");
|
System.out.println("4. Quitter");
|
||||||
System.out.println("Votre choix : ");
|
System.out.print("Merci de faire votre choix : ");
|
||||||
choix = sc.nextInt();
|
choix = sc.nextInt();
|
||||||
switch (choix) {
|
switch (choix) {
|
||||||
case 1 :
|
case 1 :
|
||||||
|
@@ -8,7 +8,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Classe métier
|
||||||
* @author dthev
|
* @author dthev
|
||||||
*/
|
*/
|
||||||
public class Bibliotheque {
|
public class Bibliotheque {
|
||||||
@@ -17,6 +17,7 @@ public class Bibliotheque {
|
|||||||
// 5. ISBN doit être unique
|
// 5. ISBN doit être unique
|
||||||
public boolean addLivre(Livre b) {
|
public boolean addLivre(Livre b) {
|
||||||
//ajoute b si valide et si n'existe pas - à écrire
|
//ajoute b si valide et si n'existe pas - à écrire
|
||||||
|
lesLivres.add(b);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,11 +4,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque.Métier;
|
package com.mycompany.bibliotheque.Métier;
|
||||||
|
|
||||||
|
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
||||||
|
import com.mycompany.bibliotheque.Métier.Livre;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author dthev
|
* @author dthev
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Emprunt {
|
public class Emprunt {
|
||||||
|
|
||||||
// TODO: logique métier d'emprunt
|
// TODO: logique métier d'emprunt
|
||||||
public static boolean effectuerEmprunt(Utilisateur u, Livre l) {
|
public static boolean effectuerEmprunt(Utilisateur u, Livre l) {
|
||||||
if (l.isEmprunte()) {
|
if (l.isEmprunte()) {
|
||||||
|
@@ -5,9 +5,8 @@
|
|||||||
package com.mycompany.bibliotheque.Métier;
|
package com.mycompany.bibliotheque.Métier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe métier qui gère les livres
|
*
|
||||||
* @author dthev
|
* @author dthev
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Livre {
|
public class Livre {
|
||||||
|
@@ -4,16 +4,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque.Métier;
|
package com.mycompany.bibliotheque.Métier;
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author dthev
|
* @author dthev
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.mycompany.bibliotheque.Métier.Livre;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Utilisateur {
|
public class Utilisateur {
|
||||||
private String nom;
|
private String nom;
|
||||||
private List<Livre> emprunts;
|
private List<Livre> emprunts;
|
||||||
|
|
||||||
public Utilisateur(String nom) {
|
public Utilisateur(String nom) {
|
||||||
|
@@ -2,8 +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/UnitTests/JUnit4TestClass.java to edit this template
|
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
|
||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque.Métier;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
|
import com.mycompany.bibliotheque.Métier.Bibliotheque;
|
||||||
|
import com.mycompany.bibliotheque.Métier.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;
|
@@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
|
|
||||||
*/
|
|
||||||
package com.mycompany.bibliotheque.Contrôle;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author dthev
|
|
||||||
*/
|
|
||||||
public class LivreValideTest {
|
|
||||||
|
|
||||||
public LivreValideTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of isValidIsbn method, of class LivreValide.
|
|
||||||
*/
|
|
||||||
@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 of isValidTitre method, of class LivreValide.
|
|
||||||
*/
|
|
||||||
@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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of isValidAuteur method, of class LivreValide.
|
|
||||||
*/
|
|
||||||
@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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of isLongueurTitreValid method, of class LivreValide.
|
|
||||||
*/
|
|
||||||
@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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -2,16 +2,13 @@
|
|||||||
* 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/UnitTests/JUnit4TestClass.java to edit this template
|
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
|
||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque.Métier;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
|
import com.mycompany.bibliotheque.Métier.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.*;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author dthev
|
|
||||||
*/
|
|
||||||
public class LivreTest {
|
public class LivreTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCreationLivre() {
|
public void testCreationLivre() {
|
||||||
@@ -19,8 +16,8 @@ public void testCreationLivre() {
|
|||||||
|
|
||||||
assertNotNull(b);
|
assertNotNull(b);
|
||||||
assertEquals("1984", b.getTitre());
|
assertEquals("1984", b.getTitre());
|
||||||
assertEquals("George Orwell", 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
|
||||||
}
|
}
|
||||||
}
|
}
|
175
src/test/java/com/mycompany/bibliotheque/LivreValideTest.java
Normal file
175
src/test/java/com/mycompany/bibliotheque/LivreValideTest.java
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
|
import com.mycompany.bibliotheque.Contrôle.LivreValide;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dthev
|
||||||
|
*/
|
||||||
|
public class LivreValideTest {
|
||||||
|
|
||||||
|
public LivreValideTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of isValidIsbn method, of class LivreValide.
|
||||||
|
* @author Emile
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsValidIsbn() {
|
||||||
|
System.out.println("isValidIsbn");
|
||||||
|
|
||||||
|
|
||||||
|
//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");
|
||||||
|
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
public void testIsContenuTitreValid() {
|
||||||
|
System.out.println("isLongueurTitreValid");
|
||||||
|
String titre = "";
|
||||||
|
boolean expResult = false;
|
||||||
|
boolean result = LivreValide.isLongueurTitreValid(titre);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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));
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
|
import com.mycompany.bibliotheque.Métier.Utilisateur;
|
||||||
|
import com.mycompany.bibliotheque.Métier.Livre;
|
||||||
|
import java.util.List;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dthev
|
||||||
|
*/
|
||||||
|
public class UtilisateurTest {
|
||||||
|
|
||||||
|
public UtilisateurTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getNom method, of class Utilisateur.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetNom() {
|
||||||
|
System.out.println("getNom");
|
||||||
|
Utilisateur instance = null;
|
||||||
|
String expResult = "";
|
||||||
|
String result = instance.getNom();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
// TODO review the generated test code and remove the default call to fail.
|
||||||
|
fail("The test case is a prototype.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getEmprunts method, of class Utilisateur.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetEmprunts() {
|
||||||
|
System.out.println("getEmprunts");
|
||||||
|
Utilisateur instance = null;
|
||||||
|
List<Livre> expResult = null;
|
||||||
|
List<Livre> result = instance.getEmprunts();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
// TODO review the generated test code and remove the default call to fail.
|
||||||
|
fail("The test case is a prototype.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of emprunterLivre method, of class Utilisateur.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEmprunterLivre() {
|
||||||
|
System.out.println("emprunterLivre");
|
||||||
|
Livre livre = null;
|
||||||
|
Utilisateur instance = null;
|
||||||
|
boolean expResult = false;
|
||||||
|
boolean result = instance.emprunterLivre(livre);
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
// TODO review the generated test code and remove the default call to fail.
|
||||||
|
fail("The test case is a prototype.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user