Test add Game, add GameType and add Game with GameType done.
This commit is contained in:
@@ -32,7 +32,7 @@ public class Stock {
|
|||||||
private String ref;
|
private String ref;
|
||||||
|
|
||||||
@Column(name="GAME_DAILY_PRICE", nullable = false)
|
@Column(name="GAME_DAILY_PRICE", nullable = false)
|
||||||
private Long dailyPrice;
|
private Double dailyPrice;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval = true)
|
||||||
@JoinColumn(name="GAME_ID")
|
@JoinColumn(name="GAME_ID")
|
||||||
|
|||||||
@@ -3,14 +3,19 @@ package fr.eni.demo;
|
|||||||
import fr.eni.demo.bll.ClientService;
|
import fr.eni.demo.bll.ClientService;
|
||||||
import fr.eni.demo.bll.GameTypeService;
|
import fr.eni.demo.bll.GameTypeService;
|
||||||
import fr.eni.demo.bll.LocationService;
|
import fr.eni.demo.bll.LocationService;
|
||||||
|
import fr.eni.demo.bll.StockService;
|
||||||
import fr.eni.demo.bo.Client;
|
import fr.eni.demo.bo.Client;
|
||||||
import fr.eni.demo.bo.GameType;
|
import fr.eni.demo.bo.GameType;
|
||||||
import fr.eni.demo.bo.Location;
|
import fr.eni.demo.bo.Location;
|
||||||
|
import fr.eni.demo.bo.Stock;
|
||||||
import org.junit.jupiter.api.DisplayName;
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class DemoApplicationTests {
|
class DemoApplicationTests {
|
||||||
|
|
||||||
@@ -20,6 +25,8 @@ class DemoApplicationTests {
|
|||||||
private LocationService locationService;
|
private LocationService locationService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private GameTypeService gameTypeService;
|
private GameTypeService gameTypeService;
|
||||||
|
@Autowired
|
||||||
|
private StockService stockService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("-- Test add Client --")
|
@DisplayName("-- Test add Client --")
|
||||||
@@ -79,4 +86,46 @@ class DemoApplicationTests {
|
|||||||
System.out.println(gameType);
|
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<GameType> 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user