idx-academy / mic-orders

3 stars 0 forks source link

Project Documentation

Prerequisites:

General

The project is organized in way of mix Hexagonal architecture + DDD + Clean architecture.

code - Java source code

e2e - Karate tests

Project structure:

Build and run app

cd code
mvn clean install

Options to enable/disable different test types:

To run integration tests docker-compose should be up.

Spin up locally required infrastructure
docker-compose -f ./orders-boot/src/test/resources/compose/docker-compose.yml up
Run app
java -jar -DLOCAL_PASSWORD=<LOCAL_PASSWORD> -Dspring.profiles.active=local ./code/orders-boot/target/orders-boot-*.jar

where LOCAL_PASSWORD is password applied on local env for all users by default which are specified in auth.users section in application-local.yml.

By default, each time when app starts the keypair for JWT is generated. It means after restart app JWT should be generated. Later we add possibility to use static keys.

Swagger http://localhost:8080/retail/swagger-ui/index.html.

Run karate tests

cd e2e/karate
mvn clean verify -Dkarate.env=local 

It is possible to specify username/password via env vars which will be used by karate, defaults see in config-local-secret.yml

mvn clean verify -Dkarate.env=local -DUSERNAME=<TEST_USERNAME> -DPASSWORD=<TEST_PASSWORD>

where TEST_USERNAME and TEST_PASSWORD is username and password with which app started

Run tests (Mutation + Code coverage)

mvn -B clean verify -DskipITs pitest:mutationCoverage pitest:report-aggregate-module

Mutation report is located <ROOT_MODULE>/target/pit-reports/index.html

UT coverage is located <ROOT_MODULE>/jacoco-report-aggregate/target/site/jacoco-aggregate/index.html

To apply format for java and pom.xml run mvn with the format-apply profile Example: mvn clean install -DskipTests -P format-apply

Obtain JWT locally

curl --location 'http://localhost:8080/retail/auth/token' \
--header 'Content-Type: application/json' \
--data '{
    "username": "<USERNAME>",
    "password":  "<PASSWORD>"
}'

References