Vehicle registration coding task
Implement a Springboot Project to create some APIS. Latest Springboot and Java 11 is preferred
- Create person
- Create vehicle (unique by Vehicle Registration)
- Link person to a vehicle
- Unlink person from a vehicle Rules
- A person can be linked to multiple regos
- A rego can be linked to only one person Data need not be persisted in DB. In memory storage is fine. Relevant tests, API specs and assumptions are to be documented
- Spring Boot - version 2.5.2
- Java 11
- Liquibase - version 4.3.5 (To create database DDL scripts)
- Lombok - version 1.18.20
- Swagger2 - version 3.0.0
- H2 database
- Checkout the source code from this GIT repository.
- Build the project with
mvn install
- Change directory to <PROJECT_ROOT>\target
- Run the Spring boot application by running the below command
<JAVA_HOME>\bin\java.exe -jar registration-0.0.1-SNAPSHOT.jar com.vehicle.registration.VehicleRegistrationApplication
The Swagger API specification JSON is in the below file.
https://github.com/balajit123/vehicle-registration/blob/main/src/main/resources/swagger/vehicle-registration-0.0.1.json
Access the swagger api documentation from the localhost url while the application is running.
http://localhost:8080/swagger-ui.html#/vehicle-registration-controller
- Create Person
curl --location --request POST 'http://localhost:8080/vehicle-registration/create-person' \
--header 'Content-Type: application/json' \
--data-raw '{
"firstName": "John",
"lastName": "Bob"
}'
* Create Vehicle
curl --location --request POST 'http://localhost:8080/vehicle-registration/create-vehicle' \
--header 'Content-Type: application/json' \
--data-raw '{
"registrationNumber": "ASD-89P"
}'
* Link Person to Vehicle
curl --location --request PATCH 'http://localhost:8080/vehicle-registration/link-person-to-vehicle' \
--header 'Content-Type: application/json' \
--data-raw '{
"firstName": "John",
"lastName": "Bob",
"registrationNumber": "ASD-89P"
}'
* Unlink Person from Vehicle
curl --location --request DELETE 'http://localhost:8080/vehicle-registration/unlink-person-from-vehicle' \
--header 'Content-Type: application/json' \
--data-raw '{
"firstName": "John",
"lastName": "Bob",
"registrationNumber": "ASD-89P"
}'
* Get Person Vehicle Registrations
curl --location --request GET 'http://localhost:8080/vehicle-registration/get-person-vehicle-registrations?firstName=John&lastName=Bob'