Compare commits
2 Commits
09cf3836c2
...
steve
Author | SHA1 | Date | |
---|---|---|---|
d8ec5254df | |||
bc740d970e |
20
pom.xml
20
pom.xml
@@ -30,7 +30,25 @@
|
|||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.1.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.14.0</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -30,16 +30,18 @@ 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 Morgann: implémenter la validation
|
||||||
boolean valide = false;
|
return 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) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean contenuValide = titre.matches(".*[a-zA-Z].*[a-zA-Z].*");
|
||||||
|
|
||||||
|
return contenuValide;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ public class GestionBibliotheque {
|
|||||||
Livre l1 = new Livre("Le secret des secrets","Dan Brown","9782709668385",true);
|
Livre l1 = new Livre("Le secret des secrets","Dan Brown","9782709668385",true);
|
||||||
Utilisateur u1 = new Utilisateur("Alice");
|
Utilisateur u1 = new Utilisateur("Alice");
|
||||||
|
|
||||||
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("2. Ajouter un livre");
|
System.out.println("2. Ajouter un livre");
|
||||||
|
@@ -8,15 +8,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe métier
|
* Classe métier
|
||||||
* @author dthev
|
* @author dthev
|
||||||
*/
|
*/
|
||||||
public class Bibliotheque {
|
public class Bibliotheque {
|
||||||
private List<Livre> lesLivres = new ArrayList<>();
|
private List<Livre> lesLivres = new ArrayList<>();
|
||||||
|
|
||||||
// 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);
|
lesLivres.add(b);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ package com.mycompany.bibliotheque.Métier;
|
|||||||
public class Livre {
|
public class Livre {
|
||||||
private String titre;
|
private String titre;
|
||||||
private String auteur;
|
private String auteur;
|
||||||
private String isbn; // ISBN sous forme de chaîne
|
private String isbn; // ISBN sous forme de chaîne
|
||||||
private Boolean emprunte;
|
private Boolean emprunte;
|
||||||
|
|
||||||
public Livre(String titre, String auteur, String isbn, Boolean emprunte) {
|
public Livre(String titre, String auteur, String isbn, Boolean emprunte) {
|
||||||
|
@@ -14,10 +14,10 @@ public class LivreTest {
|
|||||||
public void testCreationLivre() {
|
public void testCreationLivre() {
|
||||||
Livre b = new Livre("1984", "George Orwell", "1234567890123", false);
|
Livre b = new Livre("1984", "George Orwell", "1234567890123", false);
|
||||||
|
|
||||||
assertNotNull(b);
|
assertNotNull("L'objet Livre ne peut pas être nulle !", b);
|
||||||
assertEquals("1984", b.getTitre());
|
assertEquals("Titre du Livre incorrect", "1984", b.getTitre());
|
||||||
assertEquals("George Orwell", b.getAuteur()); // corrigé
|
assertEquals("Auteur du Livre incorrect", "George Orwel", b.getAuteur()); // corrigé
|
||||||
assertEquals("1234567890123", b.getIsbn());
|
assertEquals("ISBN du Livre incorrect", "1234567890123", b.getIsbn());
|
||||||
assertFalse(b.isEmprunte()); // si la méthode existe
|
assertFalse("Le livre n'est pas censé être emprunté", b.isEmprunte()); // si la méthode existe
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -39,7 +39,7 @@ 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() {
|
||||||
@@ -74,30 +74,12 @@ public class LivreValideTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testIsLongueurTitreValid() {
|
public void testIsLongueurTitreValid() {
|
||||||
System.out.println("isLongueurTitreValid");
|
System.out.println("isLongueurTitreValid");
|
||||||
|
String titre = "";
|
||||||
//test 1 : aucune valeur saisie
|
boolean expResult = false;
|
||||||
System.out.println("Test avec aucune valeur saisie");
|
boolean result = LivreValide.isLongueurTitreValid(titre);
|
||||||
String titre1 = "";
|
assertEquals(expResult, result);
|
||||||
boolean expResult1 = false;
|
// TODO review the generated test code and remove the default call to fail.
|
||||||
boolean result1 = LivreValide.isLongueurTitreValid(titre1);
|
fail("The test case is a prototype.");
|
||||||
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");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,11 +90,21 @@ public class LivreValideTest {
|
|||||||
public void testIsContenuTitreValide() {
|
public void testIsContenuTitreValide() {
|
||||||
System.out.println("isTitreValid");
|
System.out.println("isTitreValid");
|
||||||
String titre = "";
|
String titre = "";
|
||||||
boolean expResult = false;
|
assertFalse("Le titre ne doit pas être vide !", LivreValide.isContenuTitreValide(titre));
|
||||||
boolean result = LivreValide.isContenuTitreValide(titre);
|
titre = null;
|
||||||
assertEquals(expResult, result);
|
assertFalse("Le titre ne peut pas être nul !", LivreValide.isContenuTitreValide(titre));
|
||||||
// TODO review the generated test code and remove the default call to fail.
|
titre = "Ti";
|
||||||
fail("The test case is a prototype.");
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user