Compare commits
3 Commits
a606a72476
...
SalomeeVai
Author | SHA1 | Date | |
---|---|---|---|
|
c742e0cb46 | ||
|
0a660cecf2 | ||
|
f90dc16401 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,5 +1 @@
|
|||||||
/target/
|
/target/
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
*.xml
|
|
||||||
>>>>>>> 6e8f63e2c0b4f89a6f46070511e8ce4223af4bb7
|
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
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
|
||||||
@@ -12,7 +14,6 @@ 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;
|
||||||
@@ -27,13 +28,21 @@ 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.)
|
||||||
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
|
||||||
@@ -44,13 +53,31 @@ 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 Morgann: implémenter la validation
|
// TODO: implémenter la validation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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: implémenter la validation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isDisponible (Livre leLivre){
|
||||||
|
boolean valide = true;
|
||||||
|
if(leLivre.isEmprunte()){
|
||||||
|
valide = false;
|
||||||
|
}
|
||||||
|
return valide;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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.print("Merci de faire votre choix : ");
|
System.out.println("Votre choix : ");
|
||||||
choix = sc.nextInt();
|
choix = sc.nextInt();
|
||||||
switch (choix) {
|
switch (choix) {
|
||||||
case 1 :
|
case 1 :
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
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.*;
|
||||||
@@ -24,12 +25,10 @@ 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");
|
||||||
@@ -37,7 +36,6 @@ 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(" ");
|
||||||
@@ -76,22 +74,44 @@ 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() {
|
||||||
System.out.println("isValidTitre");
|
System.out.println("isValidTitre");
|
||||||
String Titre = "";
|
|
||||||
boolean expResult = false;
|
System.out.println("Test1 : un titre comportant un '<'");
|
||||||
boolean result = LivreValide.isValidTitre(Titre);
|
String Titre1 = "La chat<perché";
|
||||||
assertEquals(expResult, result);
|
boolean expResult1 = false;
|
||||||
// TODO review the generated test code and remove the default call to fail.
|
boolean result1 = LivreValide.isValidTitre(Titre1);
|
||||||
fail("The test case is a prototype.");
|
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.
|
* Test of isValidAuteur method, of class LivreValide.
|
||||||
* @author Medhi/Steve
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsValidAuteur() {
|
public void testIsValidAuteur() {
|
||||||
@@ -106,7 +126,6 @@ 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() {
|
||||||
@@ -119,28 +138,25 @@ public class LivreValideTest {
|
|||||||
fail("The test case is a prototype.");
|
fail("The test case is a prototype.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsContenuTitreValid() {
|
public void testIsDisponible(){
|
||||||
System.out.println("isLongueurTitreValid");
|
System.out.println("isDisponible");
|
||||||
String titre = "";
|
Livre unLivre = new Livre("Le comte de MonteCristo","Alexandre Dumas", "1234567891245", false);
|
||||||
boolean expResult = false;
|
|
||||||
boolean result = LivreValide.isLongueurTitreValid(titre);
|
System.out.println("Test1 : un livre disponible");
|
||||||
}
|
boolean result1 = LivreValide.isDisponible(unLivre);
|
||||||
/**
|
assertTrue("Le chevron < n'est pas censé etre accepté", result1);
|
||||||
* Test of isTitreValid method, of class LivreValide.
|
System.out.println("Le test1 est validé");
|
||||||
* @author Steve
|
System.out.println("--------------------------------------------------");
|
||||||
*/
|
System.out.println(" ");
|
||||||
@Test
|
|
||||||
public void testIsContenuTitreValide() {
|
unLivre.setEmprunte(true);
|
||||||
System.out.println("isTitreValid");
|
System.out.println("Test2 : un livre indiisponible");
|
||||||
String titre = "";
|
boolean result2 = LivreValide.isDisponible(unLivre);
|
||||||
boolean expResult = false;
|
assertFalse("Le chevron < n'est pas censé etre accepté", result2);
|
||||||
boolean result = LivreValide.isContenuTitreValide(titre);
|
System.out.println("Le test2 est validé");
|
||||||
|
System.out.println("--------------------------------------------------");
|
||||||
assertEquals(expResult, result);
|
System.out.println(" ");
|
||||||
// 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