Currently our integration tests run against an in-memory HSQLDB whose schema is created by Hibernate based on our JPA annotations. This has differences from the MariaDB schema created by our Flyway migrations. It is also a completely different database engine so who knows what other differences there are. This proposal changes this so that it will instead use [Testcontainers](https://testcontainers.com/) to spin up a MariaDB Docker container that then has the Flyway migrations ran before being used in tests. Pros: * Same database engine in tests as production * Flyway migrations are tested * Database schema is the same in tests as production (`NOT NULL` constraints, foreign keys, and so on) Cons: * *Much* slower test executions and they will get slower over time as more migrations are added Co-authored-by: Nico Athanassiadis <nico@dsv.su.se> Reviewed-on: #57 Reviewed-by: Nico Athanassiadis <nico@dsv.su.se>
Working with the API
The API is protected by OAuth 2 acting as a resource server verifying tokens using token introspection.
When developing it uses a locally running instance of an
authorization server
that is run inside Docker. It can be started with docker compose -f docker-compose.yml up
.
Since there is no frontend to interact with the authorization server there's a helper script in
GetToken.java that can be run directly with java GetToken.java
to run through the authorization flow
and get an access token.
Once the token has been obtained go to the Swagger UI to interact with the API. Click the "Authorize" button in the top right and paste the access token to log in.
Code formatting
This project uses prettier-java
to format all Java code. To reformat the code run
./mvnw validate frontend:npm@reformat -pl .
.
Yes it's a mouthful but unfortunately the prettier-maven-plugin
does not work due to an outstanding issue.
The formatting is validated by CI, but you should do it beforehand with a simple ./mvnw verify -pl .
.
Making IntelliJ format for you
For this to work you also need to have Node.js
installed and configured under Settings -> Language & Frameworks -> Node.js
and the file you're saving must be able to compile otherwise no formatting
can be performed.
Go to Settings -> Language & Frameworks -> JavaScript -> Prettier
and then check
Automatic Prettier Configuration
, set Run for files
to **/*.{java}
,
and finally check Run on save
.