---------------------Steps to set up the project:---------------------
-
Install Java (https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html)
-
Install Maven (https://maven.apache.org/install.html)
-
Install PostgreSQL database (https://www.postgresql.org/download/windows/). When setting up, make sure user “postgres” is assigned a password “postgres”
-
Create database called bookinator and assign user postgres as an owner
-
Import project to an IDE (but as you wish, cmd can be still sufficient)
-
In the project's root folder run "mvn flyway:migrate". That will run all the database migrations, setting up the db schema and initializing with data
-
If you touch something in those migrations (sql files located in bookinator\src\main\resources\db\migration), you might get in trouble. To add any new sql scripts, create a new migration file (e.g V3__new.sql). If you really need to edit existing scripts, you should drop the database and run the command from step 6 again. If it anything looks suspicious rebuild the project (either find the button in IDE or run "mvn clean install").
-
To run all the tests, use command "mvn test" To run DAO tests: mvn clean test -Dtest=com.bookinator.api.dao.* -Dsurefire.useFile=false | findstr /V "Context Bootstap Migrate Printer Runner support xml Validate DEBUG WARNING compiler maven" To run API tests: mvn test -Dtest=com.bookinator.api.controller.* -Dsurefire.useFile=false
-
There is no separate test database. It can be added easily, but for the sake of setup simplicity it was not. However, all the SQL transactions taking place in DAO unit tests get rolled back upon test completion, so no worries here.
-
To run the project, navigate to bookinator\src\main\java\com\bookinator\api and run the BookinatorApplication.java. In IDE it can be done with one click on the run button. In cmd, run "mvn spring-boot:run".
-
To view dependencies or add a new one, go to pom.xml in the project root folder.
---------------------An overview of supporting technologies used in the project:---------------------
-
Spring Boot framework - whole project is based on that
-
Flyway - database migration tool
-
JUnit - for unit testing
-
MyBatis - for mapping SQL with Java
-
JWT as authorization token mechanism
---------------------An overview the project structure:---------------------
-
"src/main/java/.../controller" -- where REST controllers are stored.
-
"src/main/java/.../dao" -- interfaces with the database methods. In "resources/.../dao" -- the SQL queries implementations are stored.
-
"resources/db/migration" -- where database schema and dump data scripts are stored.
-
"src/main/java/.../model" -- where classes that incorporate db entities and data transfer objects are stored.
-
"src/main/java/.../resources" -- where API responses classes are stored (deep inside they include DTO).
-
"src/main/java/.../security" -- where security stuff is stored.
-
"test/java/..." -- where tests are stored
-
pom.xml -- where project dependencies are stored