This application is written in Java8, using the spring-boot-parent package.
javax.inject is used to benefit from spring-boot's autowiring features while staying compliant to javax standards.
spring-boot-starter-web package is used to provide a RESTful HTTP api.
hibernate
and spring-boot-starter-data-jpa
are used. Data is stored in a file based h2db.
Models of persisted entities contain only the minimum set of properties to make the application runnable and meaningful to use.
The application has no concept of an audiologist. Having multiple appointments at the same time (with multiple audiologist) would technically be possible but lead to confusion. The model would have to be updated.
Routes like /appointments/next_week
break the rules of RESTful APIs but very much simplify the usage in this case.
The API communicates with database models to the outside world. A production-ready application would probably separate internal and external data representations to hide private or unnecessary data or provide additional information.
There is only one unit- and one API integration-test to demonstrate testing approach.
Run the application via mvn spring-boot:run
from the project root.
You can access the API at localhost:8080.
POST /customers
- create a new customerGET /customers
- retrieve all customersGET /customers/{id}
- retrieve a specific customer
Example to create a customer:
POST /customers
Content-Type: application/json
Accept: application/json
Body:
{
"firstName": "Max",
"lastName": "Mustermann"
}
POST /appointments/{customerId}
- create a new appointmentGET /appointments
- get all appointmentsGET /appointments/{customerId}/next
- get next appointment of customerGET /appointments/{customerId}/last
- get last appointment of customerGET /appointments/next_week
- get next weeks appointments
Example to create an appointment:
Customer with {customerId}
must exist.
POST /appointments/{customerId}
Content-Type: application/json
Accept: application/json
Body:
{
"date": "2016-11-29T13:30:00"
}
Execute tests by running mvn verify
.