This API program processes two JSON files and calculates the average cost of a property. The program is written in Java and is executed via shell (.sh) and batch (.bat) scripts.
There is no graphical user interface (GUI) or API endpoint for accessing the results. Instead, running the provided .sh script with the necessary input files processes the data and displays the output directly in the console.
Dowbload the code from Github
git clone git@github.com:FAME-DEV/brightbeam-api.git
cd brightbeam-api Download the Brightbeam API files and navigate to the brightbeam-api folder. The brightbeam_api_run.sh file is located inside this folder.
The brightbeam_api_run.sh script build and create a jar file and executes the brightbeam-api-0.0.1.jar Java application, setting JSON file paths dynamically.
- Accepts file paths as command-line arguments.
- Defaults to pre-configured file paths if no arguments are provided.
Before running the script, ensure the following:
- Java is installed (
java -versionto check). - The
brightbeam-apifolder is in the same directory asbrightbeam_api_run.sh. - Grant execution permissions to the script:
chmod +x brightbeam_api_run.sh
You can specify the input files as arguments:
./brightbeam_api_run.sh <file1_path> <file2_path>./brightbeam_api_run.sh /home/user/dublin_trees.json /home/user/dublin-property.csv"If no arguments are provided, the script uses predefined file paths:
To modify the default file paths, open the brightbeam_api_run.sh file in a text editor and update the file path variables with your desired values before running the script.
nano brightbeam_api_run.shMake changes in the file. Press CTRL + X to exit. Press Y to save changes. Press Enter to confirm.
the script uses predefined file paths
./brightbeam_api_run.sh- If two arguments are passed, they are used as file paths.
- If no arguments are provided, the script defaults to predefined file paths.
- The script sets the necessary environment variables and executes the Java application to process the input files.
This program provides a straightforward way to compute the average property cost by simply running a script with or without file path arguments.
output on console like this Properties with tall trees 41: average cost : €1095486.4668292683 Properties with short trees 178: average cost : €543757.9113483146
Note: I created only 2 junit test cases for cost logic, on file reading and parsing process not wrote any junit test case