Update LUDO_USER and LUDO_DB. Update Client.Location mandatory, so fix on unit test

This commit is contained in:
Olivier PARPAILLON
2025-07-09 12:23:47 +02:00
parent 0e5748bc81
commit e633ec5a5f
3 changed files with 30 additions and 31 deletions

View File

@@ -27,7 +27,7 @@ public class Client {
@Column(nullable = false, unique = true) @Column(nullable = false, unique = true)
private String email; private String email;
@OneToOne @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "LOCATION_ID") @JoinColumn(name = "LOCATION_ID")
private Location location; private Location location;
} }

View File

@@ -3,9 +3,9 @@ spring:
name: demo1 name: demo1
#Connection to DB #Connection to DB
datasource: datasource:
url: jdbc:sqlserver://localhost;databasename=ludotheque;integratedSecurity=false;encrypt=false;trustServerCertificate=false url: jdbc:sqlserver://localhost;databasename=LUDO_DB;integratedSecurity=false;encrypt=false;trustServerCertificate=false
username: sa username: LUDO_USER
password: Pa$$w0rd password: LUDO_PWD
#Options to DB #Options to DB
jpa: jpa:

View File

@@ -28,30 +28,32 @@ class DemoApplicationTests {
@Autowired @Autowired
private StockService stockService; private StockService stockService;
@Test // DEPREACTED CAUSE : Cant add Client without Location
@DisplayName("-- Test add Client --") // @Test
void testAddClient() { // @DisplayName("-- Test add Client --")
//Création de l'objet client // void testAddClient() {
Client client = new Client(); // Client client = new Client();
client.setEmail("olivier@test.fr"); // client.setEmail("olivier@test.fr");
client.setNom("Parpaillon"); // client.setNom("Parpaillon");
client.setPrenom("Olivier"); // client.setPrenom("Olivier");
//
clientService.add(client); // clientService.add(client);
System.out.println(client); // System.out.println(client);
} // }
//
@Test // DEPRECATED CAUSE : Orphan removal on Client.Location,
@DisplayName("-- Test add Location --") // so if you add Location without Client, it will be deleted by the ORM
void testAddLocation() { // @Test
Location location = new Location(); // @DisplayName("-- Test add Location --")
location.setRue("18 Rue de la Paix"); // void testAddLocation() {
location.setCodePostal("75000"); // Location location = new Location();
location.setVille("Paris"); // location.setRue("18 Rue de la Paix");
// location.setCodePostal("75000");
locationService.add(location); // location.setVille("Paris");
System.out.println(location); //
} // locationService.add(location);
// System.out.println(location);
// }
@Test @Test
@DisplayName("-- Test add Client with Location --") @DisplayName("-- Test add Client with Location --")
@@ -67,7 +69,6 @@ class DemoApplicationTests {
location.setRue("666 Rue des Enfers"); location.setRue("666 Rue des Enfers");
location.setCodePostal("44000"); location.setCodePostal("44000");
location.setVille("Nantes"); location.setVille("Nantes");
locationService.add(location);
//Ajout de la location au client //Ajout de la location au client
client.setLocation(location); client.setLocation(location);
@@ -110,12 +111,10 @@ class DemoApplicationTests {
// Création des genres de jeu // Création des genres de jeu
GameType gameTypeFPS = new GameType(); GameType gameTypeFPS = new GameType();
gameTypeFPS.setName("FPS"); gameTypeFPS.setName("FPS");
// gameTypeService.add(gameTypeFPS);
System.out.println(gameTypeFPS); System.out.println(gameTypeFPS);
GameType gameTypeOnline = new GameType(); GameType gameTypeOnline = new GameType();
gameTypeOnline.setName("Multijoueur"); gameTypeOnline.setName("Multijoueur");
// gameTypeService.add(gameTypeOnline);
System.out.println(gameTypeOnline); System.out.println(gameTypeOnline);
List<GameType> gameTypes = new ArrayList<>(); List<GameType> gameTypes = new ArrayList<>();