Skip to content

Instantly share code, notes, and snippets.

@maykonmeier
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maykonmeier/d56db33f7a454b0132eb to your computer and use it in GitHub Desktop.
Save maykonmeier/d56db33f7a454b0132eb to your computer and use it in GitHub Desktop.
Practicing Java + Spring

Job request

You should develop an API which has this features:

  1. Should be a DispatcherServlet
  2. Should use Spring 3 (3.1 or 3.2)
  3. Should have a filter for only logged routes (described below)
  4. Only login page could be accessible without login
  5. Hibernate is optional but is a suggestion
  6. Should use maven (v3.0.5)

API

API should follow patterns as REST API, using HTTP methods as POST, PUT, DELETE, GET, etc. Should use default request like:

  1. Get all employees, route should be: GET /employees
  2. Get a single employee, route should be: GET /employee/1
  3. Get object using filters: GET /employees?limit=10&offset=10&sort=desc

REST [https://en.wikipedia.org/wiki/Representational_state_transfer]

Objects

  • Objects must be persisted into a PostgreSQL database after each change;
  • Objects need to be represented by a single entity object;

Employee

Entity: id(pk), name, responsibility(fk), wage(double), active(bool), responsible(fk)(optional)

Responsibility

Entity: id(pk), name(varchar), description(varchar)

User

Entity: id(pk), username(varchar), password(md5(varchar)), active(bool)

What API should do

  1. Get a list of employees from a business;
  2. Get a list of actives/inactives employees (using query filter '?')
  3. Get a list of employees by responsibility;
  4. Add/update a single employee/responsibility (PUT/POST);
  5. Soft-delete an employee (solf-delete should turn false/true active field);
  6. Associate an employee to his responsible (using column pk responsible);
  7. Get a list of employees who I am responsible for;
  8. When DELETE a responsible, server should turn empty all employees which had this one as responsible;
  9. API must only respond when request is authorized using Basic Authentication (using user table for username and password);
  10. Otherwise API must respond with a 401 - Unauthorized;

Observations (important)

  1. The only column possible null for entities is responsible into entity Employee. Every others are required;
  2. Rules described above should be implemented;
  3. Rules which are missing could be "created" by you and documented in some place;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment