diff --git a/pom.xml b/pom.xml
index 42eb6a3..fcb0b92 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,6 +27,12 @@
spring-boot-starter-test
test
+
+ org.springframework.boot
+ spring-boot-starter-web
+ RELEASE
+ compile
+
diff --git a/src/main/java/fr/aminelouveaau/cartes/model/Card.java b/src/main/java/fr/aminelouveaau/cartes/model/Card.java
new file mode 100644
index 0000000..84416c3
--- /dev/null
+++ b/src/main/java/fr/aminelouveaau/cartes/model/Card.java
@@ -0,0 +1,23 @@
+package fr.aminelouveaau.cartes.model;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Card {
+ private final Shape shape;
+ private final Number number;
+
+ @JsonCreator
+ public Card(@JsonProperty("shape") Shape shape, @JsonProperty("number") Number number) {
+ this.shape = shape;
+ this.number = number;
+ }
+
+ public Shape getShape() {
+ return shape;
+ }
+
+ public Number getNumber() {
+ return number;
+ }
+}
diff --git a/src/main/java/fr/aminelouveaau/cartes/service/GameService.java b/src/main/java/fr/aminelouveaau/cartes/service/GameService.java
index 8f60e49..2314db7 100644
--- a/src/main/java/fr/aminelouveaau/cartes/service/GameService.java
+++ b/src/main/java/fr/aminelouveaau/cartes/service/GameService.java
@@ -1,8 +1,8 @@
package fr.aminelouveaau.cartes.service;
+import fr.aminelouveaau.cartes.model.Card;
import fr.aminelouveaau.cartes.model.Number;
import fr.aminelouveaau.cartes.model.Shape;
-import javafx.util.Pair;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -17,7 +17,7 @@ public class GameService {
private List shapeOrder;
private List numberOrder;
- private List> deck = new ArrayList<>();
+ private Stack deck = new Stack<>();
@PostConstruct
public void init() {
@@ -33,14 +33,14 @@ public class GameService {
return numberOrder;
}
- public List> getDeck() {
+ public List getDeck() {
return deck;
}
private void createDeck() {
Arrays.stream(Shape.values()).forEach(shape -> {
Arrays.stream(Number.values()).forEach(number -> {
- deck.add(new Pair<>(shape, number));
+ deck.push(new Card(shape, number));
});
});
Collections.shuffle(deck);
diff --git a/src/test/java/fr/aminelouveaau/cartes/CartesApplicationTests.java b/src/test/java/fr/aminelouveaau/cartes/CartesApplicationTests.java
index edeba90..d51e0b5 100644
--- a/src/test/java/fr/aminelouveaau/cartes/CartesApplicationTests.java
+++ b/src/test/java/fr/aminelouveaau/cartes/CartesApplicationTests.java
@@ -1,9 +1,7 @@
package fr.aminelouveaau.cartes;
-import fr.aminelouveaau.cartes.model.Number;
-import fr.aminelouveaau.cartes.model.Shape;
+import fr.aminelouveaau.cartes.model.Card;
import fr.aminelouveaau.cartes.service.GameService;
-import javafx.util.Pair;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
@@ -17,18 +15,19 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@SpringBootTest
class CartesApplicationTests {
+ public static final int CARDS_PER_HAND = 10;
@InjectMocks
GameService gameService;
@BeforeEach
public void setUp() {
- ReflectionTestUtils.setField(gameService, "cardHandNumber", 10);
+ ReflectionTestUtils.setField(gameService, "cardHandNumber", CARDS_PER_HAND);
gameService.init();
}
@Test
void testDeckGeneration() {
- List> deck = gameService.getDeck();
+ List deck = gameService.getDeck();
assertThat(deck.size()).isNotEqualTo(0).withFailMessage("Deck is empty");
assertThat(deck.size()).isEqualTo(4 * 13).withFailMessage("Deck is not complete");
}