To run the application you have several options:
- Run through Intellij , by running the DraftTicketApplication configuration
- Run through command line via command :
./gradlew bootRun
- Run through the Gradle bootRun task
- Run gradle built bootJar:
- Create the jar by running ./gradlew bootJar
- navigate to build/libs and the DraftTicketApplication-0.0.1-SNAPSHOT.jar should be visible
- Execute the jar file via the following command:
java -jar .\DraftTicketApplication-0.0.1-SNAPSHOT.jar
The DraftTicketApplication structure is quite straightforward.
The main package name is
com.product.ticketapp
.
The com.product.ticketapp.controllers
package holds the DraftTicketController, which is used as the main API for POST
requests, and the ValidationExceptionsControllerAdvice, which is an ControllerAdvice class on how to deal with
validation exceptions(since normally on validation responses there are no error messages, or they are messy)
The com.product.ticketapp.entities
package holds all the required entities/data structures for the whole application:
- DraftTicketRequest - the request object needed to be submitted on each request
- DraftTicketResponse - the response of the POST method containing all the prices/costs
- Luggage - data structure corresponding to a passengers' luggage with a dummy field
- Passenger - data structure representing the passenger
- Ticket - data structure representing individual passengers tickets/prices
- ValidationErrorResponse - data structure used when there are validation errors
The com.product.ticketapp.interfaces
package contains the TicketInterface, which could be used for different services.
The com.product.ticketapp.services
package contains the DraftTicketService service, which is responsible for all of
the price calculations and the construction of the response entity.
There are 3 main testing packages contained in the application:
com.product.ticketapp.FullTest
- Which tests the application end to end and confirms that everything is working.com.product.ticketapp.SmokeTests
- Which checks correct bean instantiationscom.product.ticketapp.UnitTests
- Contains the unit tests for the DraftTicketServicecom.product.ticketapp.ValidationTests
- Tests the spring validation layer and error messages
To test the acceptance criteria I used both the output from the FullTest.java, and the output from running the application and using postman to submit a POST request. Screenshots can be seen bellow: