merge avec main (risque de problèmes potenciels)
This commit is contained in:
commit
46b32190d0
@ -9,12 +9,19 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class Main extends Application {
|
||||
public class AppMain extends Application {
|
||||
private Scene scene = new Scene(new Pane());
|
||||
private ScreenController gestionnaireDePages = new ScreenController(scene);
|
||||
|
||||
public static boolean testMode;
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException{
|
||||
|
||||
String res = getParameters().getNamed().get("testMode");
|
||||
testMode = res!=null&&res.equals("true");
|
||||
|
||||
|
||||
ScreenController.addScreen("Acceuil",FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fp/fp.fxml")));
|
||||
|
||||
//TODO Ajouter les pages d'admin pour l'ajout des usages
|
||||
@ -28,7 +35,6 @@ public class Main extends Application {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Thread.sleep(5000);
|
||||
launch(args);
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ import fr.univ_amu.iut.model.Usage;
|
||||
public class Donnees {
|
||||
private static Academie academieSelectionee = null;
|
||||
private static Thematique thematiqueSelectionee = null;
|
||||
private static Discipline disciplineSelectionee = Discipline.Toutes;
|
||||
private static Discipline disciplineSelectionee = null;
|
||||
private static List<Usage> usagesObtenus;
|
||||
|
||||
public static List<Usage> getUsagesObtenus() {
|
||||
@ -36,7 +36,7 @@ public class Donnees {
|
||||
if(thematiqueSelectionee == Donnees.thematiqueSelectionee){
|
||||
thematiqueSelectionee = null;
|
||||
}
|
||||
System.out.println("Thematique selectionée : %s".formatted((thematiqueSelectionee == null)? "Aucune Thematique" : thematiqueSelectionee.getNom()));
|
||||
System.out.println("Thematique selectionée : %s".formatted(thematiqueSelectionee));
|
||||
Donnees.thematiqueSelectionee = thematiqueSelectionee;
|
||||
}
|
||||
public static Discipline getDisciplineSelectionee() {
|
||||
@ -44,9 +44,9 @@ public class Donnees {
|
||||
}
|
||||
public static void setDisciplineSelectionee(Discipline disciplineSelectionee) {
|
||||
if(disciplineSelectionee == Donnees.disciplineSelectionee){
|
||||
disciplineSelectionee = Discipline.Toutes;
|
||||
disciplineSelectionee = null;
|
||||
}
|
||||
System.out.println("Discipline Selectionee : %s".formatted(disciplineSelectionee.getNom()));
|
||||
System.out.println("Discipline Selectionee : %s".formatted(disciplineSelectionee));
|
||||
Donnees.disciplineSelectionee = disciplineSelectionee;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,6 @@ package fr.univ_amu.iut;
|
||||
|
||||
public class Launcher {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Main.main(args);
|
||||
AppMain.main(args);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ import fr.univ_amu.iut.test.DAOFactoryTest;
|
||||
public class DAOFactoryProducer {
|
||||
public static DAOFactory getFactory(DAOType type) {
|
||||
return switch (type){
|
||||
case JPA -> new DAOFactoryJPA();
|
||||
case JPA -> new DAOFactoryJPA("gestionUsagesPU");
|
||||
case JPA_MEMORY -> new DAOFactoryJPA("gestionUsagesPUMemory");
|
||||
case TEST -> new DAOFactoryTest();
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
|
@ -2,5 +2,6 @@ package fr.univ_amu.iut.dao.factory;
|
||||
|
||||
public enum DAOType {
|
||||
JPA,
|
||||
TEST
|
||||
JPA_MEMORY, // JPA, mais sans persistence (base de données en mémoire) (utilisé pour le test de JPA)
|
||||
TEST // utilisé pour le test de l'interface graphique
|
||||
}
|
||||
|
@ -37,15 +37,11 @@ public class DAOFactoryJPA implements DAOFactory {
|
||||
public DAOFactoryJPA(String unitName){
|
||||
this.unitName = unitName;
|
||||
|
||||
|
||||
insertAllHelper(createDAORegionAcademique(), RegionAcademique.toutes());
|
||||
insertAllHelper(createDAOAcademie(), Academie.toutes());
|
||||
insertAllHelper(createDAOThematique(), Thematique.toutes());
|
||||
insertAllHelper(createDAODiscipline(), Discipline.toutes());
|
||||
}
|
||||
public DAOFactoryJPA(){
|
||||
this("gestionUsagesPU");
|
||||
}
|
||||
|
||||
public EntityManager getEntityManager() {
|
||||
if(entityManager == null){
|
||||
|
@ -8,12 +8,15 @@ public class TableEntry {
|
||||
|
||||
private String nom;
|
||||
private String discipline;
|
||||
private String thematique;
|
||||
private String description;
|
||||
private String niveau;
|
||||
|
||||
public TableEntry(Usage usage) {
|
||||
nom = usage.getNom();
|
||||
thematique = usage.getThematique().getNom();
|
||||
discipline = usage.getDiscipline().getNom();
|
||||
System.out.println("DESC="+usage.getDescription());
|
||||
description = usage.getDescription();
|
||||
niveau = usage.getNiveau().getNom();
|
||||
}
|
||||
@ -34,6 +37,15 @@ public class TableEntry {
|
||||
this.discipline = discipline;
|
||||
}
|
||||
|
||||
|
||||
public String getThematique() {
|
||||
return thematique;
|
||||
}
|
||||
|
||||
public void setThematique(String thematique) {
|
||||
this.thematique = thematique;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
@ -51,4 +63,36 @@ public class TableEntry {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TableEntry that = (TableEntry) o;
|
||||
|
||||
if (nom != null ? !nom.equals(that.nom) : that.nom != null) return false;
|
||||
if (discipline != null ? !discipline.equals(that.discipline) : that.discipline != null) return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null) return false;
|
||||
return niveau != null ? niveau.equals(that.niveau) : that.niveau == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = nom != null ? nom.hashCode() : 0;
|
||||
result = 31 * result + (discipline != null ? discipline.hashCode() : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (niveau != null ? niveau.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TableEntry{" +
|
||||
"nom='" + nom + '\'' +
|
||||
", discipline='" + discipline + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", niveau='" + niveau + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.univ_amu.iut.fp;
|
||||
|
||||
import fr.univ_amu.iut.AppMain;
|
||||
import fr.univ_amu.iut.Donnees;
|
||||
import fr.univ_amu.iut.dao.DAODiscipline;
|
||||
import fr.univ_amu.iut.dao.DAOThematique;
|
||||
@ -18,6 +19,7 @@ import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
@ -27,7 +29,6 @@ import javafx.event.ActionEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@ -43,6 +44,9 @@ public class Controller implements Initializable {
|
||||
@FXML
|
||||
private Pane stackPaneFrance;
|
||||
|
||||
@FXML
|
||||
private TextField barreDeRecherche;
|
||||
|
||||
@FXML
|
||||
private AnchorPane discipline;
|
||||
|
||||
@ -52,26 +56,27 @@ public class Controller implements Initializable {
|
||||
@FXML
|
||||
private Button recherche;
|
||||
|
||||
List<String> listNomThematique = new ArrayList<>();
|
||||
@FXML
|
||||
private Button rechercheTextuelle;
|
||||
|
||||
// Style des boutons
|
||||
Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255, 110, 64), new CornerRadii(30), Insets.EMPTY));
|
||||
Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255, 152, 120), new CornerRadii(30), Insets.EMPTY));
|
||||
Background btSelectedBackground = new Background(new BackgroundFill(Color.rgb(255, 60, 0), new CornerRadii(30), Insets.EMPTY));
|
||||
Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255,110,64), new CornerRadii(30), Insets.EMPTY));
|
||||
Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255,152,120), new CornerRadii(30), Insets.EMPTY));
|
||||
Background btNormalSelected = new Background(new BackgroundFill(Color.rgb(255,60,0), new CornerRadii(30), Insets.EMPTY));
|
||||
|
||||
private void initFrance() {
|
||||
france = FranceBuilder.create()
|
||||
.backgroundColor(Color.web("#f5f0e1"))
|
||||
.fillColor(Color.web("#1e3d59"))
|
||||
.mousePressHandler(evt -> {
|
||||
AcademiePath academiePath = (AcademiePath) evt.getSource();
|
||||
Donnees.setAcademieSelectionee(academiePath.getAcademie());
|
||||
AcademiePath academiePath = (AcademiePath) evt.getSource();
|
||||
Donnees.setAcademieSelectionee(academiePath.getAcademie());
|
||||
})
|
||||
.selectionEnabled(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Button initButton(Object obj, int x, int y) {
|
||||
private Button initButton(Object obj,int x,int y){
|
||||
String nom = "";
|
||||
|
||||
EventHandler<ActionEvent> actionHandler;
|
||||
@ -105,7 +110,7 @@ public class Controller implements Initializable {
|
||||
|
||||
onPressHandler = event -> {
|
||||
Button bt = (Button) event.getSource();
|
||||
if (bt.getBackground().equals(btSelectedBackground)) {
|
||||
if (bt.getBackground().equals(btNormalSelected)) {
|
||||
bt.setBackground(btNormalHover);
|
||||
bt.setOnMouseEntered(onEnterHandler);
|
||||
bt.setOnMouseExited(onExitHandler);
|
||||
@ -127,7 +132,7 @@ public class Controller implements Initializable {
|
||||
}
|
||||
bt.setOnMouseEntered(null);
|
||||
bt.setOnMouseExited(null);
|
||||
bt.setBackground(btSelectedBackground);
|
||||
bt.setBackground(btNormalSelected);
|
||||
}
|
||||
};
|
||||
|
||||
@ -182,7 +187,7 @@ public class Controller implements Initializable {
|
||||
stackPaneFrance.getChildren().add(france);
|
||||
|
||||
// init
|
||||
daoFactory = DAOFactoryProducer.getFactory(DAOType.JPA);
|
||||
daoFactory = DAOFactoryProducer.getFactory(AppMain.testMode ? DAOType.TEST : DAOType.JPA);
|
||||
daoDiscipline = daoFactory.createDAODiscipline();
|
||||
daoThematique = daoFactory.createDAOThematique();
|
||||
daoUsage = daoFactory.createDAOUsage();
|
||||
@ -194,10 +199,9 @@ public class Controller implements Initializable {
|
||||
|
||||
placeButtonThematique();
|
||||
placeButtonDiscipline();
|
||||
EventHandler<ActionEvent> handler = event -> {
|
||||
//TODO Recherche en fonctions des objets selectionnés
|
||||
EventHandler<ActionEvent> handleRechercheTextuelle = event ->{
|
||||
|
||||
Donnees.setUsagesObtenus(daoUsage.findByCriterias(Donnees.getThematiqueSelectionee(), Donnees.getDisciplineSelectionee(), Donnees.getAcademieSelectionee()));
|
||||
Donnees.setUsagesObtenus(daoUsage.findByNamePart(barreDeRecherche.getText()));
|
||||
|
||||
Stage resultats = new Stage();
|
||||
try {
|
||||
@ -206,8 +210,21 @@ public class Controller implements Initializable {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
};
|
||||
recherche.setOnAction(handler);
|
||||
rechercheTextuelle.setOnAction(handleRechercheTextuelle);
|
||||
|
||||
|
||||
EventHandler<ActionEvent> handleRechercheCrieters = event ->{
|
||||
System.out.println("test");
|
||||
Donnees.setUsagesObtenus(daoUsage.findByCriterias(Donnees.getThematiqueSelectionee(),Donnees.getDisciplineSelectionee(),Donnees.getAcademieSelectionee()));
|
||||
Stage resultats = new Stage();
|
||||
try {
|
||||
resultats.setScene(new Scene(FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fResultat/FResultat.fxml"))));
|
||||
resultats.show();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
recherche.setOnAction(handleRechercheCrieters);
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,17 @@
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
|
||||
<AnchorPane id="root" prefHeight="798.0" prefWidth="1365.0" style="-fx-background-color: #f5f0e1#f5f0e1;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univ_amu.iut.fp.Controller">
|
||||
<AnchorPane id="root" prefHeight="860.0" prefWidth="1365.0" style="-fx-background-color: #f5f0e1#f5f0e1;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univ_amu.iut.fp.Controller">
|
||||
<children>
|
||||
<StackPane id="stackPaneFrance" fx:id="stackPaneFrance" layoutX="43.0" layoutY="92.0" prefHeight="649.0" prefWidth="642.0" style="-fx-background-color: blue;" />
|
||||
<AnchorPane layoutX="11.0" prefHeight="80.0" prefWidth="1019.0" style="-fx-background-color: #1e3d59#1e3d59;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
|
||||
<children>
|
||||
<TextField id="barreDeRecherche " layoutX="329.0" layoutY="27.0" prefHeight="27.0" prefWidth="372.0" promptText="Entrer nom projet :" style="-fx-background-color: #CDD0D4#CDD0D4; -fx-border-radius: 5em; -fx-background-radius: 5em;" text=" " AnchorPane.leftAnchor="329.0" AnchorPane.rightAnchor="329.0">
|
||||
<TextField fx:id="barreDeRecherche" id="barreDeRecherche" layoutX="329.0" layoutY="27.0" prefHeight="27.0" prefWidth="372.0" promptText="Entrer nom projet :" style="-fx-background-color: #CDD0D4#CDD0D4; -fx-border-radius: 5em; -fx-background-radius: 5em;" text=" " AnchorPane.leftAnchor="329.0" AnchorPane.rightAnchor="329.0">
|
||||
<cursor>
|
||||
<Cursor fx:constant="TEXT" />
|
||||
</cursor>
|
||||
</TextField>
|
||||
<Button layoutX="1066.0" layoutY="27.0" mnemonicParsing="false" text="RECHERCHER VIA LE NOM" />
|
||||
<Button fx:id="rechercheTextuelle" layoutX="1066.0" layoutY="27.0" mnemonicParsing="false" text="RECHERCHER VIA LE NOM" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<StackPane layoutX="744.0" layoutY="100.0" prefHeight="181.0" prefWidth="622.0" style="-fx-background-color: none;" AnchorPane.rightAnchor="-1.0" AnchorPane.topAnchor="100.0">
|
||||
@ -26,7 +26,6 @@
|
||||
<content>
|
||||
<AnchorPane id="discipline" fx:id="discipline" minHeight="0.0" minWidth="0.0" prefHeight="442.0" prefWidth="620.0" style="-fx-background-color: #f5f0e1#f5f0e1;">
|
||||
<children>
|
||||
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
|
@ -15,9 +15,7 @@ public class Discipline implements Serializable {
|
||||
|
||||
private static final List<Discipline> INSTANCES = new ArrayList<>();
|
||||
|
||||
|
||||
public static Discipline Toutes = new Discipline("Toutes disciplines");
|
||||
|
||||
|
||||
public static Discipline HistoireGeographie = new Discipline("Histoire-géographie");
|
||||
|
||||
public static Discipline PhysiqueChimie = new Discipline("Physique-chimie");
|
||||
|
@ -16,12 +16,7 @@ public class DAOThematiqueTest implements DAOThematique {
|
||||
|
||||
@Override
|
||||
public List<Thematique> findAll() {
|
||||
List<Thematique> liste = new ArrayList<>();
|
||||
for (int i = 0; i < 12; i++){
|
||||
Thematique thematique = new Thematique("Thematique n° "+i);
|
||||
liste.add(thematique);
|
||||
}
|
||||
return liste;
|
||||
return Thematique.toutes();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,14 +21,24 @@ public class DAOUsageTest implements DAOUsage{
|
||||
@Override
|
||||
public List<Usage> findAll() {
|
||||
List<Usage> usages = new ArrayList<>();
|
||||
for( int i = 0; i < 69 ; i++){
|
||||
for( int i = 0; i < 42 ; i++){
|
||||
Usage tmp = new Usage();
|
||||
tmp.setNom(String.valueOf(i));
|
||||
tmp.setNom("Usage n°"+ i);
|
||||
tmp.setDiscipline(Discipline.Technologie);
|
||||
tmp.setThematique(Thematique.CreationNumerique);
|
||||
tmp.setNiveau(Niveau.Tous);
|
||||
tmp.setDescription("je suis un commentaire tres long mais surtout tres utile, je sert a tester l'interface graphique et la mettre au bout de ses limtes");
|
||||
tmp.setDescription("je suis un commentaire tres long mais surtout tres utile, je sert a tester l'interface graphique et la mettre au bout de ses limites");
|
||||
usages.add(tmp);
|
||||
}
|
||||
|
||||
Usage tmp = new Usage();
|
||||
tmp.setNom("Usage spécial 1");
|
||||
tmp.setDiscipline(Discipline.PhysiqueChimie);
|
||||
tmp.setThematique(Thematique.ClasseInversee);
|
||||
tmp.setNiveau(Niveau.PremierDegre);
|
||||
tmp.setDescription("Un usage très simple, pour un test de recherche");
|
||||
usages.add(tmp);
|
||||
|
||||
return usages;
|
||||
}
|
||||
|
||||
@ -52,8 +62,15 @@ public class DAOUsageTest implements DAOUsage{
|
||||
|
||||
@Override
|
||||
public List<Usage> findByCriterias(Thematique thematique, Discipline discipline, Academie academie) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
List<Usage> list = new ArrayList<>();
|
||||
for(Usage usage : findAll()){
|
||||
if((thematique==null||thematique==usage.getThematique())&&
|
||||
(discipline==null||discipline==usage.getDiscipline())&&
|
||||
(academie==null||academie==usage.getAcademie())){
|
||||
list.add(usage);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,7 @@
|
||||
<property name="eclipselink.logging.parameters" value="true"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
<persistence-unit name="gestionUsagesPUTest" transaction-type="RESOURCE_LOCAL">
|
||||
<persistence-unit name="gestionUsagesPUMemory" transaction-type="RESOURCE_LOCAL">
|
||||
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
|
||||
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
||||
|
||||
|
@ -1,11 +1,130 @@
|
||||
package fr.univ_amu.iut;
|
||||
|
||||
import fr.univ_amu.iut.fResultat.TableEntry;
|
||||
import fr.univ_amu.iut.model.Discipline;
|
||||
import fr.univ_amu.iut.model.Niveau;
|
||||
import fr.univ_amu.iut.model.Thematique;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.testfx.api.FxRobot;
|
||||
import org.testfx.framework.junit5.ApplicationExtension;
|
||||
import org.testfx.framework.junit5.ApplicationTest;
|
||||
import org.testfx.framework.junit5.Start;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(ApplicationExtension.class)
|
||||
public class AppTest {
|
||||
|
||||
Stage stage;
|
||||
|
||||
@BeforeEach
|
||||
void setUpClass() throws Exception {
|
||||
ApplicationTest.launch(AppMain.class, "--testMode=true");
|
||||
}
|
||||
|
||||
@Start
|
||||
public void start(Stage stage) throws Exception {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_should_never_fail() {
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_initialize_stage_is_showing() {
|
||||
assertThat(stage.isShowing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void title_is_correct() {
|
||||
assertThat(stage.getTitle()).isEqualTo("Carte des académie");
|
||||
}
|
||||
|
||||
@Test
|
||||
void boutons_ajoutes() {
|
||||
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||
|
||||
assertThat(disciplinesPane.getChildren().size()).isEqualTo(Discipline.toutes().size());
|
||||
assertThat(thematiquesPane.getChildren().size()).isEqualTo(Thematique.toutes().size());
|
||||
|
||||
for(int i=0;i<disciplinesPane.getChildren().size();i++){
|
||||
String actualtext = ((Button)disciplinesPane.getChildren().get(i)).getText();
|
||||
String expectedText = Discipline.toutes().get(i).getNom();
|
||||
assertThat(actualtext).isEqualTo(expectedText);
|
||||
}
|
||||
for(int i=0;i<thematiquesPane.getChildren().size();i++){
|
||||
String actualtext = ((Button)thematiquesPane.getChildren().get(i)).getText();
|
||||
String expectedText = Thematique.toutes().get(i).getNom();
|
||||
assertThat(actualtext).isEqualTo(expectedText);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void search_should_open_window(FxRobot robot) {
|
||||
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||
Node recherche = stage.getScene().lookup("#recherche");
|
||||
|
||||
robot.clickOn(disciplinesPane.getChildren().get(1));
|
||||
robot.clickOn(thematiquesPane.getChildren().get(0));
|
||||
|
||||
|
||||
int windowsCount = Stage.getWindows().size();
|
||||
robot.clickOn(recherche);
|
||||
assertThat(Stage.getWindows().size()).isEqualTo(windowsCount+1);
|
||||
}
|
||||
@Test
|
||||
void search_window_should_have_1_result(FxRobot robot) {
|
||||
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||
Node recherche = stage.getScene().lookup("#recherche");
|
||||
|
||||
robot.clickOn(disciplinesPane.getChildren().get(1));
|
||||
robot.clickOn(thematiquesPane.getChildren().get(0));
|
||||
|
||||
|
||||
int windowsCount = Stage.getWindows().size();
|
||||
robot.clickOn(recherche);
|
||||
|
||||
Scene resultScene = Stage.getWindows().get(windowsCount).getScene();
|
||||
TableView<?> table = (TableView<?>) resultScene.lookup("#table");
|
||||
assertThat(table.getItems().size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void search_window_result_should_be_shown(FxRobot robot) {
|
||||
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||
Node recherche = stage.getScene().lookup("#recherche");
|
||||
|
||||
robot.clickOn(disciplinesPane.getChildren().get(1));
|
||||
robot.clickOn(thematiquesPane.getChildren().get(0));
|
||||
|
||||
robot.clickOn(recherche);
|
||||
|
||||
Scene resultScene = Stage.getWindows().get(1).getScene();
|
||||
TableView<TableEntry> table = (TableView<TableEntry>) resultScene.lookup("#table");
|
||||
TableEntry entry = table.getItems().get(0);
|
||||
|
||||
assertThat(entry.getNom()).isEqualTo("Usage spécial 1");
|
||||
assertThat(entry.getDescription()).isEqualTo("Un usage très simple, pour un test de recherche");
|
||||
assertThat(entry.getDiscipline()).isEqualTo(Discipline.PhysiqueChimie.getNom());
|
||||
assertThat(entry.getThematique()).isEqualTo(Thematique.ClasseInversee.getNom());
|
||||
assertThat(entry.getNiveau()).isEqualTo(Niveau.PremierDegre.getNom());
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package fr.univ_amu.iut;
|
||||
|
||||
import fr.univ_amu.iut.dao.factory.DAOFactory;
|
||||
import fr.univ_amu.iut.dao.factory.DAOFactoryProducer;
|
||||
import fr.univ_amu.iut.dao.factory.DAOType;
|
||||
import fr.univ_amu.iut.dao.jpa.DAOFactoryJPA;
|
||||
import fr.univ_amu.iut.model.*;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@ -10,11 +13,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BackendTest {
|
||||
|
||||
private static DAOFactoryJPA daoFactory;
|
||||
private static DAOFactory daoFactory;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() throws Exception {
|
||||
daoFactory = new DAOFactoryJPA("gestionUsagesPUTest");
|
||||
daoFactory = DAOFactoryProducer.getFactory(DAOType.JPA_MEMORY);
|
||||
|
||||
Usage usage = new Usage();
|
||||
usage.setNom("Premier usage");
|
||||
|
Loading…
Reference in New Issue
Block a user