This repo contains working code for a Reminder service (REST) and a simple UI for consuming the resources.
- CRUD operations
- Layered approach
- Dependency Injection using Spring
- Input data and Service validation
- Usage of Persistence framework
- Testing
- Unit Testing
- REST Client
- Postman
Description | Tool/Framework |
---|---|
Java version | JDK 1.8 |
JAX-RS Implementation | Jersey 2.23.2 |
ORM | MyBatis 3.2.3 |
Database | HSQLDB 2.4.0 |
App Server | Tomcat 7.0.47 |
IDE | IntelliJ IDEA 14 |
Build tool | Maven 3.0.5 |
Platform | iOS |
Resource Type | Resource URI | HTTP Method |
---|---|---|
Create Reminder | /reminder-service/v1/reminders | POST |
Update Reminder | /reminder-service/v1/reminders/id | PUT |
Get A Reminder | /reminder-service/v1/reminders/id | GET |
Get Reminders By DueDate and/or Status | /reminder-service/v1/reminders?dueDate=""&status="" | GET |
Delete A Reminder | /reminder-service/v1/reminders/id | DELETE |
- Clone/fork this Repo and open/import this Project into IntelliJ or Eclipse
- Build/Package the project using mvn install
- Start Tomcat and Publish reminder-service
- Test the server by http://localhost:8080. This will show the Reminder Service UI page for consuming these resources. You may get error, if you try any of the resource, as the database setup is not done
- For a quick deployment you can use the shared reminder-service-1.0-SNAPSHOT.war file, in case you didn't have time or ran into any issues.
- Install hsqldb 2.4.0
- Goto the 'hsqldb 2.4.0/hsqldb' folder and run the below command. This will start the server by creating a DB, 'reminderservdb'
- java -cp ./lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:reminderservdb --dbname.0 reminderservdb
- Now, create the table, 'Reminder' by running the TestNG Test file, CreateTableTest.java
There are 3 ways you can consume these resources. They are using simple jquery based UI, using Postman, and using REST client API.
There is a simple jquery based UI implementation to consume these resources.
- Load the page using http://localhost:8080
- Use the buttons by passing required inputs. Start with creating a Reminder as the DB is empty in the beginning.
The resources can be consumed by using below Postman collection
We can test the resources using Rest client API. These are available in the test folder RestClientTest.java.
Please make sure that the Application and DB servers are running before running this client.
There are some unit tests added into this repo
The unit tests are added mainly for Resource, Service and DAO layers. These tests will be run as part of the mvn build/install command and can also be run by mvn test command