FrancescoScandiffio / shop-totem

ShopTotem is a Java application for shopping in a supermarket. The project was realised for an examination to demonstrate test-writing capabilities of unit tests, integration tests and end-to-end tests written in BDD style, as well as the fulfilment of code quality criteria assessed through SonarCloud. Works with MySQL (via Hibernate) and MongoDB.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shop Totem

Advanced Techniques and Tools for Software Development

Java CI with Maven on ubuntu-latest Java CI with Maven on MacOS Bugs Code Smells Technical Debt Quality Gate Status Coverage Duplicated Lines (%) Maintainability Rating Coveralls coverage

Shop Totem is a desktop application that simulates a supermarket shopping system. The implementation replicates some real-world constraints, such as limiting the amount of products that can be bought based on the stock available in the warehouse (the database). It can also use either a relational database or a non-relational database, specifically MySQL and MongoDB, depending on the value of a command line parameter specified at startup.

Pre-requisites

In order to run this project is required Java8 and Docker. Having Docker-compose is recommended in order to start databases easily, although it is not mandatory. The databases will try to connect to the ports:

  • MySQL: 3306
  • MongoDB: 27017, 27018 and 27019 (due to the replica set)

Maven build

The full Maven build can be obtained through the command:

mvn clean verify

With it, all unit, integration and E2E tests with BDD will be performed. Also the required database Docker containers will be started and stopped automatically during the tests. It will also be generated the JaCoCo code coverage report. Mutation testing is disabled by default but can be executed with:

mvn org.pitest:pitest-maven:mutationCoverage

Run in production

Before running the application, it will be necessary to run the container for the chosen database. For simplicity both databases can be launched with the use of our docker-compose. That is, by simply running docker-compose up.

Alternatively only the singular containers can be launched. In case of MongoDB, a Replica set must be run, which is essential for executing transactions. This can be done with the following command:

docker run -d -p 27017:27017 -p 27018:27018 -p 27019:27019 candis/mongo-replica-set

In case of MySQL it will only be required:

docker run -d -p 3306:3306 -e MYSQL_DATABASE=" totem" -e MYSQL_ROOT_PASSWORD="" -e MYSQL_ALLOW_EMPTY_PASSWORD="yes" mysql :8.0.28

After that, when running the application, it is necessary to specify the database to use. This can be done by entering the parameter --database, with a value of choice between mysql (default) and mongo.

It is also possible to run multiple instances of the application simultaneously. However, for convenience, at the start of each new application the databases are reset and repopulated. For this reason it is advised to open all the applications at once, to avoid resetting data already inserted. In any case, if this happens, without closing the application it is possible to cancel the order. After that, the application will automatically retrieve the data from the database and be ready to use again.

About

ShopTotem is a Java application for shopping in a supermarket. The project was realised for an examination to demonstrate test-writing capabilities of unit tests, integration tests and end-to-end tests written in BDD style, as well as the fulfilment of code quality criteria assessed through SonarCloud. Works with MySQL (via Hibernate) and MongoDB.

License:MIT License


Languages

Language:Java 98.3%Language:Gherkin 1.7%