@@ -45,10 +45,10 @@ Maven wrapper (`./mvnw`) is included, so Maven installation is optional.
4545open target/site/jacoco/index.html
4646
4747# Run specific test class
48- ./mvnw test -Dtest=BooksControllerTest
48+ ./mvnw test -Dtest=PlayersControllerTests
4949
5050# Run specific test method
51- ./mvnw test -Dtest=BooksControllerTest#testGetAllBooks
51+ ./mvnw test -Dtest=PlayersControllerTests#getAll_playersExist_returnsOkWithAllPlayers
5252
5353# Run tests without rebuilding
5454./mvnw surefire:test
@@ -99,25 +99,25 @@ java -jar target/java.samples.spring.boot-*.jar
9999
100100### Database Management
101101
102- This project uses ** H2 in-memory database for tests** and ** SQLite for runtime** .
102+ This project uses ** SQLite in-memory database for tests** and ** SQLite for runtime** .
103103
104104** Runtime (SQLite)** :
105105
106106``` bash
107107# Database auto-initializes on first startup
108- # Pre-seeded database ships in storage/books -sqlite3.db
108+ # Pre-seeded database ships in storage/players -sqlite3.db
109109
110110# To reset database to seed state
111- rm storage/books -sqlite3.db
111+ rm storage/players -sqlite3.db
112112# WARNING: spring.jpa.hibernate.ddl-auto=none disables schema generation
113113# Deleting the DB will cause startup failure - restore from backup or manually reinitialize
114114
115- # Database location: storage/books -sqlite3.db
115+ # Database location: storage/players -sqlite3.db
116116```
117117
118- ** Tests (H2 )** :
118+ ** Tests (SQLite )** :
119119
120- - In-memory database per test run
120+ - In-memory database per test run (jdbc:sqlite::memory:)
121121- Automatically cleared after each test
122122- Configuration in ` src/test/resources/application.properties `
123123
@@ -181,34 +181,37 @@ src/main/java/ar/com/nanotaboada/java/samples/spring/boot/
181181├── Application.java # @SpringBootApplication entry point
182182
183183├── controllers/ # REST endpoints
184- │ └── BooksController .java # @RestController, OpenAPI annotations
184+ │ └── PlayersController .java # @RestController, OpenAPI annotations
185185
186186├── services/ # Business logic
187- │ └── BooksService .java # @Service, @Cacheable
187+ │ └── PlayersService .java # @Service, @Cacheable
188188
189189├── repositories/ # Data access
190- │ └── BooksRepository .java # @Repository, Spring Data JPA
190+ │ └── PlayersRepository .java # @Repository, Spring Data JPA
191191
192- └── models/ # Domain models
193- ├── Book.java # @Entity, JPA model
194- ├── BookDTO.java # Data Transfer Object, validation
195- └── UnixTimestampConverter.java # JPA converter
192+ ├── models/ # Domain models
193+ │ ├── Player.java # @Entity, JPA model
194+ │ └── PlayerDTO.java # Data Transfer Object, validation
195+
196+ └── converters/ # Infrastructure converters
197+ └── IsoDateConverter.java # JPA converter for ISO-8601 dates
196198
197199src/test/java/ # Test classes
198- ├── BooksControllerTest .java
199- ├── BooksServiceTest .java
200- └── BooksRepositoryTest .java
200+ ├── PlayersControllerTests .java
201+ ├── PlayersServiceTests .java
202+ └── PlayersRepositoryTests .java
201203```
202204
203205** Key patterns** :
204206
205207- Spring Boot 4 with Spring MVC
206208- Spring Data JPA for database operations
207- - Custom validation annotations for ISBN and URL
209+ - Custom validation annotations for PlayerDTO
208210- OpenAPI 3.0 annotations for Swagger docs
209211- ` @Cacheable ` for in-memory caching
210212- DTOs with Bean Validation (JSR-380)
211213- Actuator for health monitoring and metrics
214+ - JPA derived queries and custom JPQL examples
212215- Maven multi-module support ready
213216
214217## API Endpoints
@@ -217,11 +220,13 @@ src/test/java/ # Test classes
217220
218221| Method | Path | Description |
219222| --------| ------| -------------|
220- | ` GET ` | ` /books ` | Get all books |
221- | ` GET ` | ` /books/{id} ` | Get book by ID |
222- | ` POST ` | ` /books ` | Create new book |
223- | ` PUT ` | ` /books/{id} ` | Update book |
224- | ` DELETE ` | ` /books/{id} ` | Delete book |
223+ | ` GET ` | ` /players ` | Get all players |
224+ | ` GET ` | ` /players/{id} ` | Get player by ID |
225+ | ` GET ` | ` /players/search/league/{league} ` | Search players by league |
226+ | ` GET ` | ` /players/search/squadnumber/{squadNumber} ` | Get player by squad number |
227+ | ` POST ` | ` /players ` | Create new player |
228+ | ` PUT ` | ` /players/{id} ` | Update player |
229+ | ` DELETE ` | ` /players/{id} ` | Delete player |
225230| ` GET ` | ` /actuator/health ` | Health check |
226231| ` GET ` | ` /swagger-ui.html ` | API documentation |
227232
@@ -265,7 +270,7 @@ java --version # Should be 25.x
265270pkill -f " spring-boot:run"
266271
267272# Reset database
268- rm storage/books .db
273+ rm storage/players-sqlite3 .db
269274```
270275
271276### Test failures
@@ -275,7 +280,7 @@ rm storage/books.db
275280./mvnw test -X
276281
277282# Run single test for debugging
278- ./mvnw test -Dtest=BooksControllerTest#testGetAllBooks -X
283+ ./mvnw test -Dtest=PlayersControllerTests#getAll_playersExist_returnsOkWithAllPlayers -X
279284```
280285
281286### Maven wrapper issues
@@ -309,40 +314,53 @@ Open <http://localhost:8080/swagger-ui.html> - Interactive documentation with "T
309314# Health check
310315curl http://localhost:8080/actuator/health
311316
312- # Get all books
313- curl http://localhost:8080/books
317+ # Get all players
318+ curl http://localhost:8080/players
319+
320+ # Get player by ID
321+ curl http://localhost:8080/players/1
322+
323+ # Search players by league (Premier League)
324+ curl http://localhost:8080/players/search/league/Premier
314325
315- # Get book by ID
316- curl http://localhost:8080/books/1
326+ # Get player by squad number (Messi #10)
327+ curl http://localhost:8080/players/search/squadnumber/10
317328
318- # Create book
319- curl -X POST http://localhost:8080/books \
329+ # Create player
330+ curl -X POST http://localhost:8080/players \
320331 -H " Content-Type: application/json" \
321332 -d ' {
322- "isbn": "9780132350884",
323- "title": "Clean Code",
324- "author": "Robert C. Martin",
325- "published": 1217548800,
326- "pages": 464,
327- "description": "A Handbook of Agile Software Craftsmanship",
328- "website": "https://www.pearson.com/en-us/subject-catalog/p/clean-code-a-handbook-of-agile-software-craftsmanship/P200000009044"
333+ "firstName": "Leandro",
334+ "middleName": "Daniel",
335+ "lastName": "Paredes",
336+ "dateOfBirth": "1994-06-29",
337+ "squadNumber": 5,
338+ "position": "Defensive Midfield",
339+ "abbrPosition": "DM",
340+ "team": "AS Roma",
341+ "league": "Serie A",
342+ "starting11": false
329343 }'
330344
331- # Update book
332- curl -X PUT http://localhost:8080/books /1 \
345+ # Update player
346+ curl -X PUT http://localhost:8080/players /1 \
333347 -H " Content-Type: application/json" \
334348 -d ' {
335- "isbn": "9780132350884",
336- "title": "Clean Code - Updated",
337- "author": "Robert C. Martin",
338- "published": 1217548800,
339- "pages": 464,
340- "description": "Updated description",
341- "website": "https://www.pearson.com/example"
349+ "id": 1,
350+ "firstName": "Emiliano",
351+ "middleName": null,
352+ "lastName": "Martínez",
353+ "dateOfBirth": "1992-09-02",
354+ "squadNumber": 23,
355+ "position": "Goalkeeper",
356+ "abbrPosition": "GK",
357+ "team": "Aston Villa FC",
358+ "league": "Premier League",
359+ "starting11": true
342360 }'
343361
344- # Delete book
345- curl -X DELETE http://localhost:8080/books/1
362+ # Delete player
363+ curl -X DELETE http://localhost:8080/players/21
346364```
347365
348366## Important Notes
@@ -353,8 +371,10 @@ curl -X DELETE http://localhost:8080/books/1
353371- ** Java version** : Must use JDK 25 for consistency with CI/CD
354372- ** Maven wrapper** : Always use ` ./mvnw ` instead of ` mvn ` for consistency
355373- ** Database** : SQLite is for demo/development only - not production-ready
356- - ** H2 for tests** : Tests use in-memory H2 , runtime uses SQLite
374+ - ** SQLite for tests** : Tests use in-memory SQLite (jdbc:sqlite::memory:) , runtime uses file-based SQLite
357375- ** OpenAPI annotations** : Required for all new endpoints (Swagger docs)
358376- ** Caching** : Uses Spring's ` @Cacheable ` - clears on updates/deletes
359- - ** Validation** : Custom ISBN and URL validators in BookDTO
360- - ** Unix timestamps** : Published dates stored as Unix timestamps (seconds since epoch)
377+ - ** Validation** : Bean Validation (JSR-380) annotations in PlayerDTO
378+ - ** ISO-8601 dates** : Dates stored as ISO-8601 strings for SQLite compatibility
379+ - ** Search methods** : Demonstrates JPA derived queries (findBySquadNumber) and custom JPQL (findByLeagueContainingIgnoreCase)
380+ - ** Squad numbers** : Jersey numbers (natural key) separate from database IDs
0 commit comments