Verb | Endpoint | Description |
---|---|---|
GET | /track/{userId}/habits/{habitId} | Retrieves track records for a given habit of a given user |
PUT | /track/{userId}/habits/{habitId} | Creates/update track records for a given habit of a given user |
./gradlew test
You can created a fat JAR that contains all dependencies and a Tomcat server to run the application as follows:
./gradlew build
docker-compose up --build
It's recommend to use docker-compose
to start the following components on your local machine:
- REST webservice
- PostgreSQL database
Dockerfile
describes the application's Docker image and expects an existing JAR (see Build).
--build
makes sure that this Docker image is build each time and changes become effective.
SQL scripts in the folder src/test/resources/db
are executed automatically in alphabetical order to create the database schema and insert some test data.
You can terminate terminate all started containers as follows:
docker-compose down
It's also possible to start each component separately:
docker-compose up db
to start the databasedocker-compose up app
or./gradlew bootRun
to start the webservice (Gradle will start the service on port 9002)
Flyway is used for continuously migrating the database.
The folder src/main/resources/db/migration
contains SQL migration scripts. Every migration must comply a specific
naming pattern to be picked up by Flyway.
When starting the application, Spring automatically detects the SQL scripts and applies the migration steps to its
configured data source if they have not been run yet.
You can use the Flyway Gradle plugin to conveniently run Flyway CLI commands. It is especially useful for printing status information about migrations, validating applied migrations against the ones available on the classpath and manually migrating the database.
Note: You can specify database credentials for the Flyway Gradle plugin by passing the Gradle properties
dbUrl
,dbUser
anddbPassword
(i.e.gradle flywayInfo -PdbUrl=<db-url> -PdbUser=<db-user> -PdbPassword=<db-password>
).
Click here for an overview of available commands.
./gradlew test
The code (not) covered by tests is measured with JaCoCo.
You can call the following command to generate a HTML coverage report under build/reports/jacoco/test/html
and verify the compliance with coverage rules:
./gradlew test jacocoTestReport jacocoTestCoverageVerification
./gradlew intTest
The Spotless Gradle plugin is used the format the source code using Google Java Format. It's recommended to install and use the Google Format plugin in your IDE as well.
gradlew build
will check the code automatically and fail in case of violations.
If necessary, you can fix the code as follows:
./gradlew spotlessApply