SpringBoot Application that demonstrates REST API Development using Spring MVC, Spring Data JPA using Java 8 features
This application has two primary REST end-points that provide flight-booking information.
- GET /bookings?uid={passenger-id}
- GET /bookings/{booking-id}
Besides these two primary end-points, there are few other end-points to support the consumer apps(mobile/web). They are:
- GET /airports
- GET /airports/{iata-code}
- GET /flights
- GET /flights/{flight-id}
- GET /passengers
- GET /passengers/{passenger-id}
To test these end-points, see the API documentation section here
- Java (Programming Language)
- Spring Boot (Application Platform)
- Spring Data JPA (Data persistence)
- H2 (Database)
- JUnit, with Spring Testing (Unit & Integration Testing)
The source code can be checked out to your local and then build and run the application either from your IDE after importing to it as a maven project, or just from a command line. Follow these steps for the command-line option:
- Java 8
- Maven 3
- Git
git clone https://[email protected]/sameerean/flight-booking.git
mvn clean install
mvn spring-boot:run
The application will be available at the URL: Home.
The home screen will give you relevant links to navigate, including the API end-points.
1. [http://localhost:8080/bookings?uid=PS-10](http://localhost:8080/bookings?uid=PS-10)
2. [http://localhost:8080/bookings/FB-10](http://localhost:8080/bookings/FB-10)
API documentation can be accessed via Swagger UI
There is just one test case for this project as of now: BookingTest.java
You can run it either from:
- Command line
mvn test
-
Your IDE
Right click on this file and "Run As JUnit Testcase"
This application is using H2 in-memory database, which (database as well as data) will be removed from memory when the application goes down.
While the application is running, you can access the H2 Console if you want to see the data outside the application.
You can connect to the DB using the JDBC URL: 'jdbc:h2:mem:flight-booking' and user 'sa' with NO password.
Sample data is pre-loaded from the demonstration purpose by DataLoader.java. In a production-grade application, this will be done through a database upgrade script/task.