- Install java 11. In this tutorial I will show results for java 20.
- Check if JAVA_HOME is present in your environment variables. Add if it is not.
JAVA_HOME D:\Program Files\Java\jdk-20
- Install maven.
- Check if maven path is present in your PATH environment variable. Add if it is not.
PATH D:\Program Files\apache-maven-3.9.3\bin
- Restart terminal.
- Check your java version.
PS C:\Users\jbart> java --version
java 20.0.1 2023-04-18
Java(TM) SE Runtime Environment (build 20.0.1+9-29)
Java HotSpot(TM) 64-Bit Server VM (build 20.0.1+9-29, mixed mode, sharing)
- Check your maven version
PS C:\Users\jbart> mvn -v
Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)
Maven home: D:\Program Files\apache-maven-3.9.3
Java version: 20.0.1, vendor: Oracle Corporation, runtime: D:\Program Files\Java\jdk-20
Default locale: pl_PL, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
- Install node.js.
- Check if nodejs path is present in your PATH environment variable. Add if it is not.
C:\Program Files\nodejs\
- Also there should be present npm in your PATH variable. Add if it is not.
C:\Users\jbart\AppData\Roaming\npm
- Restart terminal.
- Check if node is working.
PS C:\Users\jbart> node --version
v19.7.0
- Check if npm is working.
PS C:\Users\jbart> npm --version
9.5.0
- Change directory into the root directory.
- Run mvn install.
- Run java -jar .\application\target\application-1.0-SNAPSHOT-jar-with-dependencies.jar.
- Change directory into the root directory.
- Run npm run build.
- Run npm install -g serve
- Run serve -s build
- Change directory into the root directory.
- Run mvn test.
Not required in the task.
- GET, POST, OPTIONS http://localhost:8500/admin
- GET, POST, OPTIONS http://localhost:8500/user
Propose a solution on how to integrate into your Java application the possibility to add some calculation rules (e.g. limits, total amount of reimbursement based on different conditions) using JavaScript.
I decided to use React on the front end, so I can easily tract current state of the form. The mechanism of state is used to ensure that proper HtmlElements are inserted into the browser window. The current total value in the user's reimbursement form is recalculated on each action:
- Distance changed
- Receipt added
- Allowance days changed
Similarly, a rule for each field should be run when form field(depending on its type):
- Changes value
- Looses focus
- Gets deleted
Depending on the outcome of the field validation, state should either be changed or remain the same. In an event of a failure, an error message should be displayed.