Make real Test for BO only
This commit is contained in:
@@ -17,15 +17,15 @@ import java.util.Optional;
|
||||
class DemoApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private ClientService clientService;
|
||||
private ClientServiceImpl clientServiceImpl;
|
||||
@Autowired
|
||||
private AdresseService adresseService;
|
||||
private AdresseServiceImpl adresseServiceImpl;
|
||||
@Autowired
|
||||
private GameTypeService gameTypeService;
|
||||
private GameTypeServiceImpl gameTypeService;
|
||||
@Autowired
|
||||
private StockService stockService;
|
||||
private StockServiceImpl stockServiceImpl;
|
||||
@Autowired
|
||||
private LocationService locationService;
|
||||
private LocationServiceImpl locationServiceImpl;
|
||||
|
||||
// DEPREACTED CAUSE : Cant add Client without Location
|
||||
// @Test
|
||||
@@ -71,7 +71,7 @@ class DemoApplicationTests {
|
||||
|
||||
//Ajout de la location au client
|
||||
client.setAdresse(adresse);
|
||||
clientService.add(client);
|
||||
clientServiceImpl.add(client);
|
||||
|
||||
System.out.println(client);
|
||||
System.out.println(adresse);
|
||||
@@ -94,7 +94,7 @@ class DemoApplicationTests {
|
||||
game.setDailyPrice(25.10);
|
||||
game.setDescription("Jeu RPG avec de multiple fin c'est incroyable");
|
||||
game.setRef("10GBRESF148KQF");
|
||||
stockService.add(game);
|
||||
stockServiceImpl.add(game);
|
||||
System.out.println(game);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class DemoApplicationTests {
|
||||
|
||||
// Ajout des genres de jeu au jeu
|
||||
game.setGameType(gameTypes);
|
||||
stockService.add(game);
|
||||
stockServiceImpl.add(game);
|
||||
System.out.println(game);
|
||||
}
|
||||
|
||||
@@ -130,16 +130,16 @@ class DemoApplicationTests {
|
||||
@DisplayName("-- Test add location game to a client --")
|
||||
void testAddLocationGame() {
|
||||
// Find a client by his ID
|
||||
Optional<Client> client = clientService.findById(1L);
|
||||
Optional<Client> client = clientServiceImpl.findById(1L);
|
||||
// Find a Game by his ID
|
||||
Optional<Stock> game = stockService.findById(1L);
|
||||
Optional<Stock> game = stockServiceImpl.findById(1L);
|
||||
|
||||
// Create the Location line for this client and the game
|
||||
Location gameLocation = new Location();
|
||||
gameLocation.setStartDate(Date.valueOf(LocalDate.of(2025, 7, 8)));
|
||||
gameLocation.setClient(client.get());
|
||||
gameLocation.setStock(game.get());
|
||||
locationService.add(gameLocation);
|
||||
locationServiceImpl.add(gameLocation);
|
||||
System.out.println(gameLocation);
|
||||
}
|
||||
|
||||
|
||||
35
src/test/java/fr/eni/demo/bo/AdresseTest.java
Normal file
35
src/test/java/fr/eni/demo/bo/AdresseTest.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package fr.eni.demo.bo;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
@SpringBootTest
|
||||
public class AdresseTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add Adresse builder : SUCCESS --")
|
||||
void testAddAdresseSuccess() {
|
||||
Adresse adresse = new Adresse();
|
||||
adresse.setCodePostal("75000");
|
||||
adresse.setRue("Rue de la paix");
|
||||
adresse.setVille("Paris");
|
||||
|
||||
assertNotNull(adresse);
|
||||
System.out.println(adresse);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add Addresse builder : FAILED --")
|
||||
void testAddAdresseFailed() {
|
||||
Adresse adresse = new Adresse();
|
||||
adresse.setCodePostal("44000");
|
||||
adresse.setRue("Rue d'Orvault");
|
||||
|
||||
assertNull(adresse.getVille());
|
||||
System.out.println(adresse);
|
||||
}
|
||||
}
|
||||
47
src/test/java/fr/eni/demo/bo/ClientTest.java
Normal file
47
src/test/java/fr/eni/demo/bo/ClientTest.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package fr.eni.demo.bo;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
@SpringBootTest
|
||||
public class ClientTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add Client builder with Adresse : SUCESS --")
|
||||
void testAddClientSuccess() {
|
||||
Client client = new Client();
|
||||
client.setEmail("olivier@test.fr");
|
||||
client.setNom("Parpaillon");
|
||||
client.setPrenom("Olivier");
|
||||
|
||||
Adresse adresse = new Adresse();
|
||||
adresse.setRue("666 Rue des Enfers");
|
||||
adresse.setCodePostal("44000");
|
||||
adresse.setVille("Nantes");
|
||||
client.setAdresse(adresse);
|
||||
|
||||
assertNotNull(adresse);
|
||||
assertNotNull(client);
|
||||
System.out.println(client);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add Client builder without Adresse : FAILED --")
|
||||
void testAddClientFail() {
|
||||
Client client = new Client();
|
||||
client.setEmail("julien@test.fr");
|
||||
client.setNom("Chateau");
|
||||
client.setPrenom("Julien");
|
||||
|
||||
assertNotNull(client);
|
||||
assertNull(client.getAdresse());
|
||||
System.out.println(client);
|
||||
System.out.println(client.getAdresse());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
21
src/test/java/fr/eni/demo/bo/GameTypeTest.java
Normal file
21
src/test/java/fr/eni/demo/bo/GameTypeTest.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package fr.eni.demo.bo;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
@SpringBootTest
|
||||
public class GameTypeTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add GameType builder : SUCCESS --")
|
||||
void testAddGameTypeSuccess() {
|
||||
GameType gt = new GameType();
|
||||
gt.setName("FPS");
|
||||
|
||||
assertNotNull(gt);
|
||||
System.out.println(gt);
|
||||
}
|
||||
}
|
||||
93
src/test/java/fr/eni/demo/bo/LocationTest.java
Normal file
93
src/test/java/fr/eni/demo/bo/LocationTest.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package fr.eni.demo.bo;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
@SpringBootTest
|
||||
public class LocationTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add Location with game and client builder : SUCCESS")
|
||||
void testAddLocationGameSuccess() {
|
||||
Adresse adresse = new Adresse();
|
||||
adresse.setVille("Paris");
|
||||
adresse.setRue("Rue de la paix");
|
||||
adresse.setCodePostal("75000");
|
||||
|
||||
assertNotNull(adresse);
|
||||
System.out.println(adresse);
|
||||
|
||||
Client client = new Client();
|
||||
client.setEmail("test@test.fr");
|
||||
client.setAdresse(adresse);
|
||||
client.setPrenom("test");
|
||||
client.setNom("test");
|
||||
|
||||
assertNotNull(client);
|
||||
System.out.println(client);
|
||||
|
||||
GameType gt = new GameType();
|
||||
gt.setName("Plateforme");
|
||||
List<GameType> gtList = new ArrayList<>();
|
||||
gtList.add(gt);
|
||||
assertNotNull(gt);
|
||||
assertThat(gtList).hasSize(1);
|
||||
System.out.println(gtList);
|
||||
|
||||
Stock stock = new Stock();
|
||||
stock.setName("Super Mario Bros");
|
||||
stock.setDescription("Jeu de plateforme pas compliqué");
|
||||
stock.setDailyPrice(8.10);
|
||||
stock.setGameType(gtList);
|
||||
stock.setRef("654POAZJIHGOG646");
|
||||
|
||||
assertNotNull(stock);
|
||||
System.out.println(stock);
|
||||
|
||||
Location l = new Location();
|
||||
l.setClient(client);
|
||||
l.setStock(stock);
|
||||
l.setStartDate(Date.valueOf(LocalDate.of(2025, 7, 8)));
|
||||
assertNotNull(l);
|
||||
System.out.println(l);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add location with game but without client builder : FAILED --")
|
||||
void testAddLocationGameFailure() {
|
||||
GameType gt = new GameType();
|
||||
gt.setName("Aventure");
|
||||
List<GameType> gtList = new ArrayList<>();
|
||||
gtList.add(gt);
|
||||
assertNotNull(gt);
|
||||
assertThat(gtList).hasSize(1);
|
||||
System.out.println(gtList);
|
||||
|
||||
Stock stock = new Stock();
|
||||
stock.setName("Tomb Raider");
|
||||
stock.setDescription("Jeu d'aventure et d'archéologie coolos");
|
||||
stock.setDailyPrice(18.10);
|
||||
stock.setGameType(gtList);
|
||||
stock.setRef("ZOIGHE45ZPIG452");
|
||||
|
||||
assertNotNull(stock);
|
||||
System.out.println(stock);
|
||||
|
||||
Location l = new Location();
|
||||
l.setStock(stock);
|
||||
l.setStartDate(Date.valueOf(LocalDate.of(2025, 7, 8)));
|
||||
assertNull(l.getClient());
|
||||
assertNotNull(l);
|
||||
System.out.println(l);
|
||||
}
|
||||
}
|
||||
56
src/test/java/fr/eni/demo/bo/StockTest.java
Normal file
56
src/test/java/fr/eni/demo/bo/StockTest.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package fr.eni.demo.bo;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
@SpringBootTest
|
||||
public class StockTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add Stock builder : SUCCESS --")
|
||||
void testAddStockBuilder() {
|
||||
GameType gt = new GameType();
|
||||
gt.setName("RPG");
|
||||
List<GameType> gtList = new ArrayList<>();
|
||||
gtList.add(gt);
|
||||
assertNotNull(gt);
|
||||
assertThat(gtList).hasSize(1);
|
||||
|
||||
Stock stock = new Stock();
|
||||
stock.setName("Baldurs Gate 3");
|
||||
stock.setDescription("Jeu RPG au possibilité infinie");
|
||||
stock.setRef("154ZOIGZ54");
|
||||
stock.setDailyPrice(15.20);
|
||||
stock.setGameType(gtList);
|
||||
|
||||
assertNotNull(stock);
|
||||
System.out.println(stock);
|
||||
System.out.println(gtList);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("-- Test add Stock builder : FAILED --")
|
||||
void testAddStockBuilderFailed() {
|
||||
GameType gt = new GameType();
|
||||
gt.setName("Plateforme");
|
||||
List<GameType> gtList = new ArrayList<>();
|
||||
gtList.add(gt);
|
||||
assertNotNull(gt);
|
||||
assertThat(gtList).hasSize(1);
|
||||
|
||||
Stock stock = new Stock();
|
||||
stock.setName("Super Mario Bros");
|
||||
stock.setDescription("Jeu de plateforme pas compliqué");
|
||||
stock.setDailyPrice(8.10);
|
||||
stock.setGameType(gtList);
|
||||
assertNull(stock.getRef());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user