Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSimcoe committed Jul 15, 2024
1 parent 1e4c775 commit 3c66dee
Show file tree
Hide file tree
Showing 28 changed files with 112 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<mat-header-cell *matHeaderCellDef>Categories</mat-header-cell>
<mat-cell *matCellDef="let game">
<mat-chip-set>
<mat-chip *ngFor="let category of game.categories">{{
category
}}</mat-chip>
@for (category of game.categories; track category) {
<mat-chip>{{ category }}</mat-chip>
}
</mat-chip-set>
</mat-cell>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
.mat-mdc-chip-set {
display: flex;
flex-wrap: wrap;
Expand All @@ -8,5 +9,6 @@
}
.mat-column-categories {
flex: 0 0 250px; /* Adjust this value based on your needs */
flex: 0 0 250px;
}
*/
15 changes: 12 additions & 3 deletions application/common-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>common-backend</artifactId>

<parent>
<groupId>fr.sciam.backtofront</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>common-backend</artifactId>
<name>Common Backend</name>

<properties>
<version.hypersistence-utils>3.8.1</version.hypersistence-utils>
</properties>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -48,7 +53,7 @@
<dependency>
<groupId>io.hypersistence</groupId>
<artifactId>hypersistence-utils-hibernate-63</artifactId>
<version>3.8.1</version>
<version>${version.hypersistence-utils}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand All @@ -60,6 +65,10 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package fr.sciam.backtofront.rest;

public record BoardGameDto() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package fr.sciam.backtofront.persistence;

import fr.sciam.backtofront.domain.Category;
import fr.sciam.backtofront.persistence.entities.BoardGameEntity;
import io.quarkus.test.TestTransaction;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.transaction.Transactional;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;

@QuarkusTest
class BoardGameEntityTest {

@Test
@Transactional
void testAllBoardGamesAreImported() {
List<BoardGameEntity> boardGames = BoardGameEntity.listAll();

assertThat(boardGames).hasSize(10);

Map<String, BoardGameEntity> boardGameMap = boardGames.stream()
.collect(Collectors.toMap(bg -> bg.name, bg -> bg));

// Test each board game
assertBoardGameMatches(boardGameMap, "Gloomhaven", 2017, Category.COOPERATIVE, Category.DUNGEON_CRAWLER);
assertBoardGameMatches(boardGameMap, "Terraforming Mars", 2016, Category.STRATEGY);
assertBoardGameMatches(boardGameMap, "Pandemic", 2008, Category.COOPERATIVE, Category.STRATEGY);
assertBoardGameMatches(boardGameMap, "Catan", 1995, Category.STRATEGY, Category.RESOURCE_MANAGEMENT);
assertBoardGameMatches(boardGameMap, "Ticket to Ride", 2004, Category.FAMILY, Category.STRATEGY);
assertBoardGameMatches(boardGameMap, "Carcassonne", 2000, Category.TILE_PLACEMENT, Category.STRATEGY);
assertBoardGameMatches(boardGameMap, "Scythe", 2016, Category.STRATEGY, Category.AREA_CONTROL);
assertBoardGameMatches(boardGameMap, "Azul", 2017, Category.ABSTRACT, Category.TILE_PLACEMENT);
assertBoardGameMatches(boardGameMap, "Codenames", 2015, Category.PARTY, Category.WORD_GAME);
assertBoardGameMatches(boardGameMap, "7 Wonders", 2010, Category.CARD_DRAFTING, Category.STRATEGY);
}

@Test
@TestTransaction
void testBoardGameInsertion() {
BoardGameEntity entity = new BoardGameEntity();
entity.name = "Dune : Imperium";
entity.releaseYear = 2020;
entity.categories.add(Category.STRATEGY);

BoardGameEntity byId = BoardGameEntity.findById(11);
assertThat(byId).isNull();

entity.persist();

byId = BoardGameEntity.findById(11);
assertThat(byId.name).isEqualTo(entity.name);
assertThat(byId.releaseYear).isEqualTo(entity.releaseYear);
assertThat(byId.categories).containsExactlyInAnyOrder(entity.categories.toArray(new Category[] {}));
}

private static void assertBoardGameMatches(
final Map<String, BoardGameEntity> boardGameMap,
final String name,
final int releaseYear,
final Category... expectedCategories) {

BoardGameEntity boardGame = boardGameMap.get(name);
assertThat(boardGame).isNotNull();
assertThat(boardGame.name).isEqualTo(name);
assertThat(boardGame.releaseYear).isEqualTo(releaseYear);
assertThat(boardGame.categories).containsExactlyInAnyOrder(expectedCategories);
}
}
git
File renamed without changes.
19 changes: 16 additions & 3 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
<packaging>pom</packaging>

<name>Back to the Front - Parent</name>
<description>Projet multi-modules avec une partie commune et 4 parties spécifiques</description>

<modules>
<module>common-backend</module>
<module>common-ui</module>
<module>javafx</module>
<module>vaadin</module>
<module>jsf</module>
<module>htmx</module>
<module>ui-resources</module>
</modules>

<properties>
Expand All @@ -30,6 +29,9 @@
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.12.2</quarkus.platform.version>
<surefire-plugin.version>3.2.5</surefire-plugin.version>
<lombok.version>1.18.34</lombok.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<assertj.version>3.26.3</assertj.version>
<skipITs>true</skipITs>
</properties>

Expand All @@ -45,9 +47,20 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

0 comments on commit 3c66dee

Please sign in to comment.