From 5095e558d6c89a41af21f0270bd471cd564b0dbc Mon Sep 17 00:00:00 2001 From: kmitresse Date: Tue, 26 Mar 2024 13:56:34 +0100 Subject: [PATCH] feat: dev-web - begin tests --- .../project/dao/AbstractDAOFactoryTest.java | 12 ++ .../test/java/uppa/project/dao/DAOTest.java | 44 +++++ .../project/dao/jpa/DAO_JPA_GameTest.java | 44 +++++ .../project/dao/jpa/DAO_JPA_PlayerTest.java | 44 +++++ .../DAO_JPA_RecoveryPasswordTokenTest.java | 44 +++++ .../project/dao/jpa/DAO_JPA_UserTest.java | 44 +++++ .../dao/jpa/Game_JPA_DAO_FactoryTest.java | 32 ++++ .../test/java/uppa/project/pojo/CardTest.java | 93 +++++++++++ .../test/java/uppa/project/pojo/DeckTest.java | 52 ++++++ .../test/java/uppa/project/pojo/GameTest.java | 105 ++++++++++++ .../java/uppa/project/pojo/PlayerTest.java | 146 ++++++++++++++++ .../pojo/RecoveryPasswordTokenTest.java | 62 +++++++ .../test/java/uppa/project/pojo/UserTest.java | 158 ++++++++++++++++++ .../provider/EntityManagerProviderTest.java | 20 +++ 14 files changed, 900 insertions(+) create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/dao/AbstractDAOFactoryTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/dao/DAOTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_GameTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_PlayerTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_RecoveryPasswordTokenTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_UserTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/Game_JPA_DAO_FactoryTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/pojo/CardTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/pojo/DeckTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/pojo/GameTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/pojo/PlayerTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/pojo/RecoveryPasswordTokenTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/pojo/UserTest.java create mode 100644 S2/DevWeb/Projet/src/test/java/uppa/project/provider/EntityManagerProviderTest.java diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/dao/AbstractDAOFactoryTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/AbstractDAOFactoryTest.java new file mode 100644 index 0000000..1d482b3 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/AbstractDAOFactoryTest.java @@ -0,0 +1,12 @@ +package uppa.project.dao; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +class AbstractDAOFactoryTest { + @Test + void getDAOFactory() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/dao/DAOTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/DAOTest.java new file mode 100644 index 0000000..8cf7984 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/DAOTest.java @@ -0,0 +1,44 @@ +package uppa.project.dao; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class DAOTest { + + @Test + void findById() { + // TODO Implement this method + fail(); + } + + @Test + void findAll() { + // TODO Implement this method + fail(); + } + + @Test + void create() { + // TODO Implement this method + fail(); + } + + @Test + void update() { + // TODO Implement this method + fail(); + } + + @Test + void delete() { + // TODO Implement this method + fail(); + } + + @Test + void findByField() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_GameTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_GameTest.java new file mode 100644 index 0000000..e506698 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_GameTest.java @@ -0,0 +1,44 @@ +package uppa.project.dao.jpa; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class DAO_JPA_GameTest { + + @Test + void findById() { + // TODO Implement this method + fail(); + } + + @Test + void findByField() { + // TODO Implement this method + fail(); + } + + @Test + void findAll() { + // TODO Implement this method + fail(); + } + + @Test + void create() { + // TODO Implement this method + fail(); + } + + @Test + void update() { + // TODO Implement this method + fail(); + } + + @Test + void delete() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_PlayerTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_PlayerTest.java new file mode 100644 index 0000000..215d1de --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_PlayerTest.java @@ -0,0 +1,44 @@ +package uppa.project.dao.jpa; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class DAO_JPA_PlayerTest { + + @Test + void findById() { + // TODO Implement this method + fail(); + } + + @Test + void findByField() { + // TODO Implement this method + fail(); + } + + @Test + void findAll() { + // TODO Implement this method + fail(); + } + + @Test + void create() { + // TODO Implement this method + fail(); + } + + @Test + void update() { + // TODO Implement this method + fail(); + } + + @Test + void delete() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_RecoveryPasswordTokenTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_RecoveryPasswordTokenTest.java new file mode 100644 index 0000000..05d09b6 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_RecoveryPasswordTokenTest.java @@ -0,0 +1,44 @@ +package uppa.project.dao.jpa; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class DAO_JPA_RecoveryPasswordTokenTest { + + @Test + void findById() { + // TODO Implement this method + fail(); + } + + @Test + void findByField() { + // TODO Implement this method + fail(); + } + + @Test + void findAll() { + // TODO Implement this method + fail(); + } + + @Test + void create() { + // TODO Implement this method + fail(); + } + + @Test + void update() { + // TODO Implement this method + fail(); + } + + @Test + void delete() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_UserTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_UserTest.java new file mode 100644 index 0000000..ef5119e --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/DAO_JPA_UserTest.java @@ -0,0 +1,44 @@ +package uppa.project.dao.jpa; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class DAO_JPA_UserTest { + + @Test + void findById() { + // TODO Implement this method + fail(); + } + + @Test + void findByField() { + // TODO Implement this method + fail(); + } + + @Test + void findAll() { + // TODO Implement this method + fail(); + } + + @Test + void create() { + // TODO Implement this method + fail(); + } + + @Test + void update() { + // TODO Implement this method + fail(); + } + + @Test + void delete() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/Game_JPA_DAO_FactoryTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/Game_JPA_DAO_FactoryTest.java new file mode 100644 index 0000000..c9713a2 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/dao/jpa/Game_JPA_DAO_FactoryTest.java @@ -0,0 +1,32 @@ +package uppa.project.dao.jpa; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class Game_JPA_DAO_FactoryTest { + + @Test + void getDAOUser() { + // TODO Implement this method + fail(); + } + + @Test + void getDAOGame() { + // TODO Implement this method + fail(); + } + + @Test + void getDAOPlayer() { + // TODO Implement this method + fail(); + } + + @Test + void getDAORecoveryPasswordToken() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/CardTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/CardTest.java new file mode 100644 index 0000000..db6df14 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/CardTest.java @@ -0,0 +1,93 @@ +package uppa.project.pojo; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class CardTest { + + static Card[] FIXTURE; + + @BeforeAll + static void setup() { + FIXTURE = new Card[]{ + // Card Value + new Card(Card.Color.HEART, Card.Value.ONE), + new Card(Card.Color.HEART, Card.Value.TWO), + new Card(Card.Color.HEART, Card.Value.THREE), + new Card(Card.Color.CLUBS, Card.Value.FOUR), + new Card(Card.Color.CLUBS, Card.Value.FIVE), + new Card(Card.Color.CLUBS, Card.Value.SIX), + new Card(Card.Color.DIAMONDS, Card.Value.SEVEN), + new Card(Card.Color.DIAMONDS, Card.Value.EIGHT), + new Card(Card.Color.DIAMONDS, Card.Value.NINE), + new Card(Card.Color.SPADES, Card.Value.TEN), + new Card(Card.Color.SPADES, Card.Value.JACK), + new Card(Card.Color.SPADES, Card.Value.QUEEN), + new Card(Card.Color.HEART, Card.Value.KING), + + // Card Color + new Card(Card.Color.HEART, Card.Value.ONE), + new Card(Card.Color.CLUBS, Card.Value.ONE), + new Card(Card.Color.DIAMONDS, Card.Value.ONE), + new Card(Card.Color.SPADES, Card.Value.ONE), + }; + } + + @Test + void getColor() { + Card.Color[] expected = new Card.Color[] { + Card.Color.HEART, + Card.Color.HEART, + Card.Color.HEART, + Card.Color.CLUBS, + Card.Color.CLUBS, + Card.Color.CLUBS, + Card.Color.DIAMONDS, + Card.Color.DIAMONDS, + Card.Color.DIAMONDS, + Card.Color.SPADES, + Card.Color.SPADES, + Card.Color.SPADES, + Card.Color.HEART, + + Card.Color.HEART, + Card.Color.CLUBS, + Card.Color.DIAMONDS, + Card.Color.SPADES, + }; + + for (int i = 0; i < expected.length; i++) { + assertEquals(expected[i], FIXTURE[i].getColor()); + } + } + + @Test + void getValue() { + Card.Value[] expected = new Card.Value[] { + Card.Value.ONE, + Card.Value.TWO, + Card.Value.THREE, + Card.Value.FOUR, + Card.Value.FIVE, + Card.Value.SIX, + Card.Value.SEVEN, + Card.Value.EIGHT, + Card.Value.NINE, + Card.Value.TEN, + Card.Value.JACK, + Card.Value.QUEEN, + Card.Value.KING, + + Card.Value.ONE, + Card.Value.ONE, + Card.Value.ONE, + Card.Value.ONE, + }; + + for (int i = 0; i < expected.length; i++) { + assertEquals(expected[i], FIXTURE[i].getValue()); + } + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/DeckTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/DeckTest.java new file mode 100644 index 0000000..0a759bb --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/DeckTest.java @@ -0,0 +1,52 @@ +package uppa.project.pojo; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class DeckTest { + + static Deck[] FIXTURE; + + @BeforeAll + static void setup() { + FIXTURE = new Deck[] { + new Deck(4, 13), + new Deck(4, 13), + }; + } + + @Test + void throw_error_on_creation_of_invalid_deck() { + assertThrows(IllegalArgumentException.class, () -> new Deck(0, 13)); + assertThrows(IllegalArgumentException.class, () -> new Deck(5, 13)); + assertThrows(IllegalArgumentException.class, () -> new Deck(1, 0)); + assertThrows(IllegalArgumentException.class, () -> new Deck(1, 15)); + } + + @Test + void get_cards() { + // TODO Implement this method + fail(); + } + + @Test + void initialize_deck() { + // TODO Implement this method + fail(); + } + + @Test + void get_same_size_when_shuffle() { + // TODO Implement this method + fail(); + } + + @Test + void get_same_cards_when_shuffle(){ + // TODO Implement this method + fail(); + } + +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/GameTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/GameTest.java new file mode 100644 index 0000000..1d6c5f0 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/GameTest.java @@ -0,0 +1,105 @@ +package uppa.project.pojo; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class GameTest { + + @Test + void test_HashCode() { + // TODO Implement this method + } + + @Test + void get_Id() { + // TODO Implement this method + } + + @Test + void get_Created_At() { + // TODO Implement this method + } + + @Test + void get_Difficulty() { + // TODO Implement this method + } + + @Test + void set_difficulty() { + // TODO Implement this method + } + + @Test + void get_nb_Rounds() { + // TODO Implement this method + } + + @Test + void set_nb_Rounds() { + // TODO Implement this method + } + + @Test + void get_nb_Colors() { + // TODO Implement this method + } + + @Test + void set_nb_Colors() { + // TODO Implement this method + } + + @Test + void getnbValuesPerColor() { + // TODO Implement this method + } + + @Test + void setNbValuesPerColor() { + // TODO Implement this method + } + + @Test + void getPlayers() { + // TODO Implement this method + fail(); + } + + @Test + void setPlayers() { + // TODO Implement this method + fail(); + } + + @Test + void getNbPlayers() { + // TODO Implement this method + fail(); + } + + @Test + void addPlayer() { + // TODO Implement this method + fail(); + } + + @Test + void getDeck() { + // TODO Implement this method + fail(); + } + + @Test + void sortPlayersByScore() { + // TODO Implement this method + fail(); + } + + @Test + void testToString() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/PlayerTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/PlayerTest.java new file mode 100644 index 0000000..d848542 --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/PlayerTest.java @@ -0,0 +1,146 @@ +package uppa.project.pojo; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class PlayerTest { + + @Test + void testHashCode() { + // TODO Implement this method + fail(); + } + + @Test + void getGame() { + // TODO Implement this method + fail(); + } + + @Test + void setGame() { + // TODO Implement this method + fail(); + } + + @Test + void getUser() { + // TODO Implement this method + fail(); + } + + @Test + void setUser() { + // TODO Implement this method + fail(); + } + + @Test + void getScore() { + // TODO Implement this method + fail(); + } + + @Test + void setScore() { + // TODO Implement this method + fail(); + } + + @Test + void updateScore() { + // TODO Implement this method + fail(); + } + + @Test + void isWinner() { + // TODO Implement this method + fail(); + } + + @Test + void setWinner() { + // TODO Implement this method + fail(); + } + + @Test + void getClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void setClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void incrementClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void getRightClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void setRightClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void incrementRightClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void getRatioRightClick() { + // TODO Implement this method + fail(); + } + + @Test + void getRapidClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void setRapidClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void incrementRapidClickCount() { + // TODO Implement this method + fail(); + } + + @Test + void getRatioRapidClick() { + // TODO Implement this method + fail(); + } + + @Test + void getDeck() { + // TODO Implement this method + fail(); + } + + @Test + void testToString() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/RecoveryPasswordTokenTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/RecoveryPasswordTokenTest.java new file mode 100644 index 0000000..63c96fa --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/RecoveryPasswordTokenTest.java @@ -0,0 +1,62 @@ +package uppa.project.pojo; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class RecoveryPasswordTokenTest { + + @Test + void getId() { + // TODO Implement this method + fail(); + } + + @Test + void getToken() { + // TODO Implement this method + fail(); + } + + @Test + void setToken() { + // TODO Implement this method + fail(); + } + + @Test + void getUser() { + // TODO Implement this method + fail(); + } + + @Test + void setUser() { + // TODO Implement this method + fail(); + } + + @Test + void getExpiresAt() { + // TODO Implement this method + fail(); + } + + @Test + void setExpiresAt() { + // TODO Implement this method + fail(); + } + + @Test + void testToString() { + // TODO Implement this method + fail(); + } + + @Test + void getExpirationDate() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/UserTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/UserTest.java new file mode 100644 index 0000000..7725b7e --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/pojo/UserTest.java @@ -0,0 +1,158 @@ +package uppa.project.pojo; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class UserTest { + + @Test + void testHashCode() { + // TODO Implement this method + fail(); + } + + @Test + void getId() { + // TODO Implement this method + fail(); + } + + @Test + void getUsername() { + // TODO Implement this method + fail(); + } + + @Test + void setUsername() { + // TODO Implement this method + fail(); + } + + @Test + void getEmail() { + // TODO Implement this method + fail(); + } + + @Test + void setEmail() { + // TODO Implement this method + fail(); + } + + @Test + void getPassword() { + // TODO Implement this method + fail(); + } + + @Test + void setPassword() { + // TODO Implement this method + fail(); + } + + @Test + void getBirth() { + // TODO Implement this method + fail(); + } + + @Test + void setBirth() { + // TODO Implement this method + fail(); + } + + @Test + void getGender() { + // TODO Implement this method + fail(); + } + + @Test + void setGender() { + // TODO Implement this method + fail(); + } + + @Test + void getAge() { + // TODO Implement this method + fail(); + } + + @Test + void verifyPassword() { + // TODO Implement this method + fail(); + } + + @Test + void getPlayedGames() { + // TODO Implement this method` + fail(); + } + + @Test + void getNbPlayedGame() { + // TODO Implement this method + fail(); + } + + @Test + void getNbWin() { + // TODO Implement this method + fail(); + } + + @Test + void getWinRate() { + // TODO Implement this method + fail(); + } + + @Test + void getNbClicks() { + // TODO Implement this method + fail(); + } + + @Test + void getNbRightClicks() { + // TODO Implement this method + fail(); + } + + @Test + void getRightClickPercentRate() { + // TODO Implement this method + fail(); + } + + @Test + void getNbRapidClicks() { + // TODO Implement this method + fail(); + } + + @Test + void getRapidClickPercentRate() { + // TODO Implement this method + fail(); + } + + @Test + void testToString() { + // TODO Implement this method + fail(); + } + + @Test + void testGetGender() { + // TODO Implement this method + fail(); + } +} diff --git a/S2/DevWeb/Projet/src/test/java/uppa/project/provider/EntityManagerProviderTest.java b/S2/DevWeb/Projet/src/test/java/uppa/project/provider/EntityManagerProviderTest.java new file mode 100644 index 0000000..bb06a5a --- /dev/null +++ b/S2/DevWeb/Projet/src/test/java/uppa/project/provider/EntityManagerProviderTest.java @@ -0,0 +1,20 @@ +package uppa.project.provider; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class EntityManagerProviderTest { + + @Test + void getInstance() { + // TODO Implement this method + fail(); + } + + @Test + void close() { + // TODO Implement this method + fail(); + } +}