Compare commits
16 Commits
SalomeeVai
...
906f075a95
Author | SHA1 | Date | |
---|---|---|---|
906f075a95 | |||
09cf3836c2 | |||
c762aac862 | |||
a606a72476 | |||
9f0f1ae00e | |||
1f44c6ee69 | |||
3f63db1a92 | |||
19d2e618c3 | |||
6e8f63e2c0 | |||
|
22bce1d53b | ||
6ec5d152eb | |||
|
f1571ced27 | ||
ca3338fe1a | |||
|
0eac6c497d | ||
|
980fc1cc7c | ||
bec1ca9f04 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1 +1,5 @@
|
|||||||
/target/
|
/target/
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
*.xml
|
||||||
|
>>>>>>> 6e8f63e2c0b4f89a6f46070511e8ce4223af4bb7
|
||||||
|
@@ -4,8 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.mycompany.bibliotheque.Contrôle;
|
package com.mycompany.bibliotheque.Contrôle;
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Métier.Livre;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe de contrôle de la classe Livre
|
* Classe de contrôle de la classe Livre
|
||||||
* @author dthev
|
* @author dthev
|
||||||
@@ -14,6 +12,7 @@ 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){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -28,6 +27,7 @@ public class LivreValide {
|
|||||||
valide = false;
|
valide = false;
|
||||||
}
|
}
|
||||||
return valide;
|
return valide;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Titre : pas de balises HTML/JS (<script>, <img>, etc.)
|
// 2. Titre : pas de balises HTML/JS (<script>, <img>, etc.)
|
||||||
@@ -53,31 +53,23 @@ public class LivreValide {
|
|||||||
|
|
||||||
// 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;
|
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: implémenter la validation
|
// TODO Steve: implémenter la validation
|
||||||
return false;
|
if (titre == null) {
|
||||||
}
|
return false;
|
||||||
|
|
||||||
public static boolean isDisponible (Livre leLivre){
|
|
||||||
boolean valide = true;
|
|
||||||
if(leLivre.isEmprunte()){
|
|
||||||
valide = false;
|
|
||||||
}
|
}
|
||||||
return valide;
|
|
||||||
};
|
boolean contenuValide = titre.matches(".*[a-zA-Z].*[a-zA-Z].*");
|
||||||
|
|
||||||
|
return contenuValide;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ public class GestionBibliotheque {
|
|||||||
System.out.println("2. 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 :
|
||||||
|
@@ -16,7 +16,7 @@ public void testCreationLivre() {
|
|||||||
|
|
||||||
assertNotNull(b);
|
assertNotNull(b);
|
||||||
assertEquals("1984", b.getTitre());
|
assertEquals("1984", b.getTitre());
|
||||||
assertEquals("George Orwel", b.getAuteur()); // corrigé
|
assertEquals("George Orwell", 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
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
package com.mycompany.bibliotheque;
|
package com.mycompany.bibliotheque;
|
||||||
|
|
||||||
import com.mycompany.bibliotheque.Contrôle.LivreValide;
|
import com.mycompany.bibliotheque.Contrôle.LivreValide;
|
||||||
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.*;
|
||||||
@@ -25,10 +24,12 @@ public class LivreValideTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of isValidIsbn method, of class LivreValide.
|
* Test of isValidIsbn method, of class LivreValide.
|
||||||
|
* @author Emile
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsValidIsbn() {
|
public void testIsValidIsbn() {
|
||||||
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");
|
||||||
@@ -36,6 +37,7 @@ public class LivreValideTest {
|
|||||||
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));
|
||||||
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(" ");
|
||||||
@@ -74,6 +76,7 @@ public class LivreValideTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of isValidTitre method, of class LivreValide.
|
* Test of isValidTitre method, of class LivreValide.
|
||||||
|
* @author Salomé/Emile
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsValidTitre() {
|
public void testIsValidTitre() {
|
||||||
@@ -106,12 +109,11 @@ public class LivreValideTest {
|
|||||||
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(" ");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of isValidAuteur method, of class LivreValide.
|
* Test of isValidAuteur method, of class LivreValide.
|
||||||
|
* @author Medhi/Steve
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsValidAuteur() {
|
public void testIsValidAuteur() {
|
||||||
@@ -126,37 +128,66 @@ public class LivreValideTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of isLongueurTitreValid method, of class LivreValide.
|
* Test of isLongueurTitreValid method, of class LivreValide.
|
||||||
|
* @author Morgann
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsLongueurTitreValid() {
|
public void testIsLongueurTitreValid() {
|
||||||
System.out.println("isLongueurTitreValid");
|
System.out.println("isLongueurTitreValid");
|
||||||
|
|
||||||
|
//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 aucune valeur saisie");
|
||||||
|
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
|
||||||
|
public void testIsContenuTitreValid() {
|
||||||
|
System.out.println("isLongueurTitreValid");
|
||||||
String titre = "";
|
String titre = "";
|
||||||
boolean expResult = false;
|
boolean expResult = false;
|
||||||
boolean result = LivreValide.isLongueurTitreValid(titre);
|
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 of isTitreValid method, of class LivreValide.
|
||||||
|
* @author Steve
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsDisponible(){
|
public void testIsContenuTitreValide() {
|
||||||
System.out.println("isDisponible");
|
System.out.println("isTitreValid");
|
||||||
Livre unLivre = new Livre("Le comte de MonteCristo","Alexandre Dumas", "1234567891245", false);
|
String titre = "";
|
||||||
|
assertFalse("Le titre ne doit pas être vide !", LivreValide.isContenuTitreValide(titre));
|
||||||
System.out.println("Test1 : un livre disponible");
|
titre = null;
|
||||||
boolean result1 = LivreValide.isDisponible(unLivre);
|
assertFalse("Le titre ne peut pas être nul !", LivreValide.isContenuTitreValide(titre));
|
||||||
assertTrue("Le chevron < n'est pas censé etre accepté", result1);
|
titre = "Ti";
|
||||||
System.out.println("Le test1 est validé");
|
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
|
||||||
System.out.println("--------------------------------------------------");
|
titre = "T";
|
||||||
System.out.println(" ");
|
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
|
||||||
|
titre = "1234";
|
||||||
unLivre.setEmprunte(true);
|
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
|
||||||
System.out.println("Test2 : un livre indiisponible");
|
titre = "Ti2";
|
||||||
boolean result2 = LivreValide.isDisponible(unLivre);
|
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
|
||||||
assertFalse("Le chevron < n'est pas censé etre accepté", result2);
|
titre = "*$!";
|
||||||
System.out.println("Le test2 est validé");
|
assertFalse("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
|
||||||
System.out.println("--------------------------------------------------");
|
titre = "Ti!";
|
||||||
System.out.println(" ");
|
assertTrue("Le titre fait au moins 2 caractères alphabétiques !", LivreValide.isContenuTitreValide(titre));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user