For this exercise you will build a simple Java web service that provides CRUD-style API access to data stored in a relational database system.
-
Create a database table that holds records representing people.
- A person record should have a unique identifier and the following additional attributes:
- name (string)
- age (integer)
- date of birth (date)
- email address (string)
- Email address has a unique constraint (case-insensitive).
- A person record should have a unique identifier and the following additional attributes:
-
Implement the following API endpoints:
Method | URI | Response Status | Request Entity | Response Entity | Side Effects |
---|---|---|---|---|---|
GET |
/people |
200 OK |
JSON-formatted representation of all the records in the people table |
||
POST |
/people |
201 Created |
JSON-formatted representation of a unique person | JSON-formatted representation of the new person, including its unique identifier | System assigns a unique identifier and inserts a record into the people table |
GET |
/people/{:id} |
200 OK |
JSON-formatted representation of the identified person | ||
PUT |
/people/{:id} |
200 OK |
JSON-formatted representation of an existing person | JSON-formatted representation of the updated person | System updates the corresponding record in the people table |
DELETE |
/people/{:id} |
204 No Content |
System deletes the corresponding record from the people table |
-
Whenever the server cannot parse a request entity as a JSON representation of a person, it should respond with
400 Bad Request
response and a JSON-formatted error representation. -
Whenever the server is able to parse a request entity as a JSON representation of a person, but the entity is invalid due to null or malformed attributes, or other validation failures, it should respond with
422 Unprocessable Entity
and a JSON-formatted representation of the encountered errors. -
Ensure that the project is buildable from the Unix command line using Maven only. Please do not submit a project that can only be built with Eclipse or other IDE.
-
Implement whatever unit and component tests you feel are useful to ensure the quality of your work. Tests should be able to run via Maven, SBT, Gradle or another command line tool that is easily installable with Homebrew or a similar package manager. Do not use GUI based tools for your testing.
-
Provide a README file and/or create whatever other documentation you would want to provide to other members of your team who may be tasked to maintain or extend the service.
The exercise should generally not take more than 3 or 4 hours, although you're free to take as much time as you'd like to work on it. If you don't finish within a few hours, that's okay; submit what you've got anyway.
To submit the exercise,
-
Push the code to a private GitHub or Bitbucket repository. We'll provide usernames for you to give access. We cannot accept email attachments or file sharing links.
-
Deploy the application to some public location where we can interact with it (e.g. Heroku or AWS).
Please follow all of the above instructions and send code that you are proud to show us!