Kudos to tutorials authors:
- https://kotlinlang.org/docs/jvm-spring-boot-restful.html
- https://medium.com/techwasti/spring-boot-mongodb-rest-api-using-kotlin-47e49729bb21
Unit tests written using embedded mongodb. To run tests execute gradle test task.
gradle test
Created MongoDB database on using free account on https://cloud.mongodb.com
To connect to database update application.properties with connection properties, e.g.:
spring.data.mongodb.uri=mongodb+srv://test-user:<password>@cluster0.6ovbl.mongodb.net/commision-calculator
Data imported using following commands in git bash console:
./mongoimport --uri mongodb+srv://test-user:<password>@cluster0.6ovbl.mongodb.net/commision-calculator --collection fee_wages --type CSV --file ./fee_wages.csv --headerline
./mongoimport --uri mongodb+srv://test-user:<password>@cluster0.6ovbl.mongodb.net/commision-calculator --collection transactions --type CSV --file ./transactions.csv --headerline
javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in certificate_request
//solved using VM option
-Djdk.tls.client.protocols=TLSv1.2
https://mongodb.github.io/mongo-java-driver/4.1/driver/tutorials/ssl/#ocsp-stapling
To prevent uploading database credentials to repo following command can be used:
git update-index --assume-unchanged src/main/resources/application.properties
https://stackoverflow.com/a/7658676/10950272
- Simple HTTP authentication for endpoint, spring security should do the job
- Consider load of app, first ideas would be:
- build query to get proper result directly from database
- cache results
- Log request to database - add log repository and log Transaction entity to it in each request. Or simplified Transaction entity with just customerId, total fee and request date.
Other things to consider would be to add failing scenarios test cases and handle them properly.