There is a major new technology that is destined to be a disruptive force in the field of transportation: the drone. Just as the mobile phone allowed developing countries to leapfrog older technologies for personal communication, the drone has the potential to leapfrog traditional transportation infrastructure.
Useful drone functions include delivery of small items that are (urgently) needed in locations with difficult access.
We have a fleet of 10 drone. A drone is capable of carrying devices, other than cameras, and capable of delivering small loads. For our use case the load is medications.
A Drone has:
- serial number (100 characters max);
- model (Lightweight, Middleweight, Cruiserweight, Heavyweight);
- weight limit (500gr max);
- battery capacity (percentage);
- state (IDLE, LOADING, LOADED, DELIVERING, DELIVERED, RETURNING).
Each Medication has:
- name (allowed only letters, numbers, ‘-‘, ‘_’);
- weight;
- code (allowed only upper-case letters, underscore and numbers);
- image (picture of the medication case).
Develop a service via REST API that allows clients to communicate with the drones (i.e. dispatch controller). The specific communicaiton with the drone is outside the scope of this task.
- registering a drone;
- loading a drone with medication items;
- checking loaded medication items for a given drone;
- checking available drones for loading;
- check drone battery level for a given drone;
- There is no need for UI;
- Prevent the drone from being loaded with more weight that it can carry;
- Prevent the drone from being in LOADING state if the battery level is below 25%;
- Introduce a periodic task to check drones’ battery levels and create history/audit event log for this.
- Input/output data must be in JSON format;
- Your project must be buildable and runnable;
- Your project must have a README file with build/run/test instructions (use DB that can be run locally, e.g. in-memory, via container);
- Required data must be preloaded in the database.
- JUnit tests are optional but advisable (if you have time);
- Advice: Show us how you work through your commit history.
Pre-Requirements Java 8 Database – H2 DB IntelliJ IDE Postman
Main Steps to Build and Run the project
-
Clone the project through GitHub repo link -> https://github.com/Dhanut/DroneService.git
-
Go to the file directory where you have cloned and go inside the repo and right click on the pom.xml file and open with IntelliJ.
- Setup the Java SDK for Java 1.8 and wait for few minutes until all maven dependencies downloaded in IntelliJ.
- Build the project and run the main Java class and ensure project is working without any error.
Pre-Inserted data to the H2 database
Once we run the application, using the data.sql file it will automatically insert the below data to H2 DB.
Testing the End Points via Postman
All the end points in this project are authenticated with the Basic Authentication. Therefore, username and password need to be configured in all the endpoints.
Username - admin
Password - admin
- Registering a drone
End Point - http://localhost:8888/api/demo/drone/register
Method – POST
Input - { "droneSerialNumber":"AB999000", "droneModel":"LIGHTWEIGHT", "droneWeight":"200", "droneBatteryCapacity":"50", "droneState":"IDLE" }
Response: -
- Load a drone with medications
Assumptions: -
- Loading drone should be available in the database.
- A Drone can be loaded if and only if it is in IDLE or LOADING state only.
- More than one medication can be loaded at the same time.
- Total weight of loading medications + drone weight should not be over 500g.
- Drone batter capacity should be over 25%.
- If the selected drone initially in LOADING state and once after the medications loaded and Total weight of loading medications + drone weight = 500g, then the state of Drone should be updated to LOADED state.
- Same medication item can be loaded for the same drone n times, if the above conditional checks pass.
- All medications that are going to load should be first available in medication table. And weight of medications always a pre-defined value. This will not change during the load stage even.
- During the medication load, the weight of drone in the database will be updated accordingly.
End Point - http://localhost:8888/api/demo/drone/load
Method – POST
Input - { "loadingDroneSerialNumber":"TR222783", "loadingTotalQuantity":2, "loadingDeliveryAddress":" No23, TownHall, Colombo", "loadingMedicationList":[{ "medicationCode" : "001_AT_77", "medicationName": "ZIAGEN", "medicationWeight": 5.00, "medicationImage": "ZIAGEN" }, { "medicationCode" : "002_ZXT_12", "medicationName": "PLENAXIS", "medicationWeight": 1.00, "medicationImage": "PLENAXIS" } ]
}
Response: -
- Checking loaded medications
End Point - http://localhost:8888/api/demo/drone/check/medications/TR222783
Method – GET
Input - Path param – {drone_serial_number}
Response: -
- Checking available drones Assumption: Drone can be available if it is in IDLE or LOADING state only.
End Point - http://localhost:8888/api/demo/drone/check/available
Method – GET
Input - Path param – NA
Response: -
- Checking battery level of drones
End Point - http://localhost:8888/api/demo/drone/check/batteryLevel/AB999000
Method – GET
Input - Path param – Path param – {drone_serial_number}
Response: -
###logging the battery level of each drone in database using a scheduler
###SNAP SHOT of H2 DATABASE
###JUNIT coverage of the project