Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

flawmop/EBI01562

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EBI01562 - Senior Java Software Developer

REST API which stores, updates, retrieves and deletes Person entities

Requirements

  1. Java 8
  2. Maven
  3. git
  4. jq (optional)

Tested in Vagrant (after (1) issue, and (2) vagrant up --provider virtualbox).

Install, test, and start REST API

  1. Clone repository
 $ git clone https://github.com/flawmop/EBI01562.git
  1. Move to cloned repository and start
 $ cd EBI01562
  1. Unit and integration testing
 $ mvn clean verify
  1. (Optional sudo yum install lynx -y) Code coverage
 $ lynx target/site/jacoco/index.html
  1. Start REST API.
 $ mvn clean spring-boot:run

User credentials

Username Password ROLE(S)
user password USER
admin password USER, ADMIN

API documentation

Summary

Action URL ROLE Operation
GET /persons USER Retrieve all users
GET /persons/{personId} USER Retrieve a single user (by id)
PATCH /persons/{personId} ADMIN Modify a person's age (by id)
POST /persons ADMIN Add a new person
PUT /persons/{personId} ADMIN Update a person (by id)
DELETE /persons/{personId} ADMIN Delete a person (by id)

Post-startup

Swagger 2 Person Controller

Example API Operations

curl -v -u user:password 127.0.0.1:8080/persons | jq
curl -v -u admin:password 127.0.0.1:8080/persons -H 'Content-type:application/json' \
        -d '{"first_name":"fn1","last_name":"ln1","age":10,"favourite_colour":"fc1","hobby":["h1.1", "h1.2"]}' | jq
curl -v -u admin:password 127.0.0.1:8080/persons -H 'Content-type:application/json' \
        -d '{"first_name":"fn2","last_name":"ln2","age":20,"favourite_colour":"fc2","hobby":["h2.1", "h2.2"]}' | jq
curl -v -u user:password 127.0.0.1:8080/persons | jq
curl -v -u user:password 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X PUT 127.0.0.1:8080/persons/1 -H 'Content-type:application/json' \
        -d '{"first_name":"fn1.1","last_name":"ln1.1","age":11,"favourite_colour":"fc1.1","hobby":["h1.11", "h1.21"]}' | jq
curl -v -u user:password 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X PATCH 127.0.0.1:8080/persons/1 -H 'Content-type:application/json' \
        -d '{"age":12}' | jq
curl -v -u user:password 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X DELETE 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X DELETE 127.0.0.1:8080/persons/2 | jq
curl -v -u user:password 127.0.0.1:8080/persons | jq

TODO

grep -r 'TODO' src/ | awk -F'TODO' '{print $2}'

About

Senior Java Software Developer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages