Table of Contents
- Pre-requisites
- Technology Stack
- Running the application locally
- Running the tests locally
- Available Endpoints
- Usecases
- Solution Structure
- JDK 17
- This project uses Lombok, so enable annotation processing in your IDE
-
Language:
Java 17
-
Compilation:
Maven
-
Framework:
SpringBoot
-
Database:
H2
-
Type-safe queries:
Querydsl
-
Entity Graph:
JPA Entity Graph
-
Open API Documentation:
springdoc-openapi
-
Java bean mappings:
MapStruct
-
Boilerplate code reducer:
Lombok
-
Logging:
SLF4J
-
Tests:
- Unit Testing:
JUnit5
- Mocking:
Mockito
- Mutation: Testing
PIT Mutation Testing
- Code Coverage:
Jacoco
- Architecture Testing:
ArchUnit
- Unit Testing:
mvn clean install -Dmaven.test.skip=true
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=test" -f ./configuration
mvn -e clean install verify
- Swagger UI:
http://localhost:8081/swagger-ui.html
- H2 Console:
http://localhost:8081/h2-console
curl -X POST "http://localhost:8081/v1/games" -H "accept: */*" -H "Accept-Language: pt_BR" -H "PlayerId: 0" -d ""
curl -X PATCH "http://localhost:8081/v1/games" -H "accept: */*" -H "Accept-Language: pt_BR" -H "PlayerId: 0"
curl -X POST "http://localhost:8081/v1/quizzes" -H "accept: */*" -H "Accept-Language: pt_BR" -H "PlayerId: 0" -d ""
curl -X POST "http://localhost:8081/v1/bets" -H "accept: */*" -H "Accept-Language: pt_BR" -H "PlayerId: 0" -H "Content-Type: application/json" -d "{\"optionId\":\"tt2576852\"}"
curl -X GET "http://localhost:8081/v1/rankings" -H "accept: */*" -H "Accept-Language: pt_BR"
- Represent your domain object
- Apply only logic that is applicable in general to the whole entity
- Represent your business actions, it’s what you can do with the application. Expect one use case for each business action.
- Pure business logic
- Define interfaces for the data that they need in order to apply some logic. One or more providers will implement the interface, but the use case doesn’t know where the data is coming from.
- The use case doesn't know who triggered it and how the results are going to be presented.
- Throws business exceptions.
- Retrieve and store data from and to a number of sources (database, network devices, file system, 3rd parties, etc.)
- Implement the interfaces defined by the use case
- Use whatever framework is most appropriate (they are going to be isolated here anyway).
- Note: if using an ORM for database access, here you'd have another set of objects in order to represent the mapping to the tables (don't use the core entities as they might be very different).
- They are ways of interacting with the application, and typically involve a delivery mechanism (e.g. REST APIs, scheduled jobs, GUI, other systems).
- Trigger a use case and convert the result to the appropriate format for the delivery mechanism
- A GUI would use MVC (or MVP) in here; the controller would trigger a use case
- Wires everything together.
- Frameworks (e.g. for dependency injection) are isolated here
- Has the "dirty details" like Main class, web server configuration, datasource configuration, etc.
- for TDD (a.k.a. Tests first, to drive design).
- Cover every little detail, aim for 100% coverage.
- “Dev to dev” documentation: What should this class do?
- Test individual classes in isolation, very fast.
- Test integration with slow parts (http, database, etc.)
- “Dev” documentation: Does this work as expected?
- Test one layer in isolation (e.g. only rest endpoint, or only data provider). Slow
- Use whatever library makes it easy
- The Clean Architecture https://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html
- Screaming Architecture http://blog.8thlight.com/uncle-bob/2011/09/30/Screaming-Architecture.html
- NODB https://blog.8thlight.com/uncle-bob/2012/05/15/NODB.html
- Hexagonal Architecture http://alistair.cockburn.us/Hexagonal+architecture
- Clean Architecture https://www.youtube.com/results?search_query=clean+architecture
- Hexagonal Architecture https://www.youtube.com/results?search_query=hexagonal+architecture
- Clean Code https://www.youtube.com/results?search_query=clean+code