Simple restful API as an example, with some CRUD operations and data storage logic:
- Context
- Getting Started
a.Prerequisites
b.Installing - Checking code coverage
- Running the Tatanka
- API Reference
- Built With
- Author
- Rental by hour, charging $5 per hour
- Rental by day, charging $20 a day
- Rental by week, charging $60 a week
- Family Rental, is a promotion that can include from 3 to 5 Rentals (of any type) with a discount of 30% of the total price
The source code was build in IntelliJ IDEA community edition as a maven project. Download or clone the repository into the desired path and import in IntelliJ. To export the project to Eclipse please read the following export to eclipse guide, however intelliJ is required in order to test for code coverage, since it was tested in that IDE.
In order to build the project, the following programas will have to be installed:
Java jdk 1.8
Maven 3.x
IntelliJ IDEA Not required for maven testing
Open a terminal or prompt and navigate to the desired folder and clone the repository
c:\Users\hiessy> cd IdeaProjects
c:\Users\hiessy\IdeaProjects> git clone https://github.com/Hiessy/Tatanka.git
Navigate into the cloned folder and run the maven test suite
c:\Users\hiessy\IdeaProjects> cd Tatanka
c:\Users\hiessy\IdeaProjects\Tatanka>mvn test
Once complete you should be able to see the BUILD SUCCESS.
It is recommended that code coverage be checked with the IntelliJ IDE. In order to do this, open up the IDE and import the project. Once complete click on Viewing Code Coverage Results for a guide on how to achieve this.
Once the tests have cleared you can run the spring boot project by packaging it with maven compiler plugin defined in the pom file. This will rerun the test suite again, so you could probably skip running the tests with maven if you plan on building
c:\Users\hiessy\IdeaProjects\Tatanka>mvn package
When the build is complete, you should see the BUILD SUCCESS message. Navigate to the target directory and run the jar package
c:\Users\hiessy\IdeaProjects\Tatanka>cd target
c:\Users\hiessy\IdeaProjects\Tatanka\target>java -jar rental-1.0-SNAPSHOT.jar
This is a self contained spring boot project with an embedded database H2 so it should start fine. Tatanka logs folder on the path where it is running and write to the rental.log file inside. Make sure there are no other programs listening on port 8080 when running Tatanka.
There is also a doc folder with the auto generated Javadoc from IntelliJ IDE.
The following show how to consume the exposed API. Data Params should be placed in json object and the Content-Type should have the application/json when required.
URL | Method | URL Params | Data Params | Success Response | Error Response |
---|---|---|---|---|---|
/v1/rental | GET | 200 | 404 | ||
/v1/rental/{rentalId} | DELETE | rentalId | 200 | 404 | |
/v1/rental | PUT | time numberOfBikes |
200 | 400 | |
/v1/user/{userId}/rental | POST | userId | time numberOfBikes rentalDateRequested |
201 | 404 400 |
/v1/user | POST | name password |
201 | 409 400 |
|
/v1/user/{name} | GET | name | 200 | 409 400 |
- Spring Boot - The web framework
- Spring HATEOAS - Following the HATEOAS principle
- Hibernate - ORM framework
- JUnit 4.12 - Unit testing framework
- Mokito - Mocking framework used
- Maven - Dependency Management
- Martin Diaz - Initial work - Hiessy