diff --git a/src/main/java/fr/eni/demo/bo/Stock.java b/src/main/java/fr/eni/demo/bo/Stock.java index 75ebce7..f465b06 100644 --- a/src/main/java/fr/eni/demo/bo/Stock.java +++ b/src/main/java/fr/eni/demo/bo/Stock.java @@ -32,7 +32,7 @@ public class Stock { private String ref; @Column(name="GAME_DAILY_PRICE", nullable = false) - private Long dailyPrice; + private Double dailyPrice; @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval = true) @JoinColumn(name="GAME_ID") diff --git a/src/test/java/fr/eni/demo/DemoApplicationTests.java b/src/test/java/fr/eni/demo/DemoApplicationTests.java index 512ccd3..6a3550c 100644 --- a/src/test/java/fr/eni/demo/DemoApplicationTests.java +++ b/src/test/java/fr/eni/demo/DemoApplicationTests.java @@ -3,14 +3,19 @@ package fr.eni.demo; import fr.eni.demo.bll.ClientService; import fr.eni.demo.bll.GameTypeService; import fr.eni.demo.bll.LocationService; +import fr.eni.demo.bll.StockService; import fr.eni.demo.bo.Client; import fr.eni.demo.bo.GameType; import fr.eni.demo.bo.Location; +import fr.eni.demo.bo.Stock; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import java.util.ArrayList; +import java.util.List; + @SpringBootTest class DemoApplicationTests { @@ -20,6 +25,8 @@ class DemoApplicationTests { private LocationService locationService; @Autowired private GameTypeService gameTypeService; + @Autowired + private StockService stockService; @Test @DisplayName("-- Test add Client --") @@ -79,4 +86,46 @@ class DemoApplicationTests { System.out.println(gameType); } + @Test + @DisplayName("-- Test add Game --") + void testAddGame() { + Stock game = new Stock(); + game.setName("Baldurs Gate 3"); + game.setDailyPrice(25.10); + game.setDescription("Jeu RPG avec de multiple fin c'est incroyable"); + game.setRef("10GBRESF148KQF"); + stockService.add(game); + System.out.println(game); + } + + @Test + @DisplayName("-- Test add Game with GameType --") + void testAddGameWithGameType() { + // Création du jeu + Stock game = new Stock(); + game.setName("Counter Strike 2"); + game.setDailyPrice(8.50); + game.setRef("454ZGOIHOZ1215EFZD"); + + // Création des genres de jeu + GameType gameTypeFPS = new GameType(); + gameTypeFPS.setName("FPS"); +// gameTypeService.add(gameTypeFPS); + System.out.println(gameTypeFPS); + + GameType gameTypeOnline = new GameType(); + gameTypeOnline.setName("Multijoueur"); +// gameTypeService.add(gameTypeOnline); + System.out.println(gameTypeOnline); + + List gameTypes = new ArrayList<>(); + gameTypes.add(gameTypeFPS); + gameTypes.add(gameTypeOnline); + + // Ajout des genres de jeu au jeu + game.setGameType(gameTypes); + stockService.add(game); + System.out.println(game); + } + }