- Prerequisites
- Technological Choices
- Running the Application
- Testing the API
- Running Tests
- Connecting to H2 Database
Java 17 or higher
- Spring Boot
- H2 Database (and in-memory database for testing)
- Spring Data JPA
- Spring Boot Starter Validation (for input validation)
- dependency management: Gradle
- logging: SLF4J (Logback)
- Jackson (for JSON serialization/deserialization)
- JUnit 5 (for unit testing)
To start the application, run the following command:
./gradlew bootRun
gradlew.bat bootRun
GET http://localhost:8080/api/teams?page=0&size=5
GET http://localhost:8080/api/teams?sortBy=name
GET http://localhost:8080/api/teams?page=0&size=10&sortBy=-budget,name
GET http://localhost:8080/api/teams/{id}
{
"id": 1,
"name": "OGC Nice",
"acronym": "OGCN",
"budget": 50000000,
"players": [
{
"id": 1,
"name": "Player 1",
"position": "Midfielder"
},
{
"id": 2,
"name": "Player 2",
"position": "Defender"
}
]
}
{
"timestamp": "2024-09-10T14:30:00",
"status": 404,
"message": "Team with id 9999 not found"
}
POST http://localhost:8080/api/teams
{
"name": "OGC Nice",
"acronym": "OGCN",
"budget": 50000000,
"players": [
{
"name": "Player 1",
"position": "Midfielder"
},
{
"name": "Player 2",
"position": "Defender"
}
]
}
{
"id": 1,
"name": "OGC Nice",
"acronym": "OGCN",
"budget": 50000000,
"players": [
{
"id": 1,
"name": "Player 1",
"position": "Midfielder"
},
{
"id": 2,
"name": "Player 2",
"position": "Defender"
}
]
}
If required fields are missing or invalid
{
"timestamp": "2024-09-10T14:30:00",
"status": 400,
"errors": {
"name": "Team name is required",
"budget": "Budget must be a positive value"
}
}
./gradlew test
gradlew.bat test
http://localhost:8080/h2-console
- JDBC URL: jdbc:h2:~/equipe-football
- User Name: sa
- Password: (empty)
Note: The test database is in-memory and will be destroyed after the application is stopped.