Yet Another Cart Manager application
Run tests with
./gradlew clean check
Note that you must have at least java 8
jdk installed in order to run the tests.
Examples assume the application is reachable on http://localhost:8080
POST /api/v1/carts HTTP/1.1
Content-Length: 17
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
{"name":"cart 1"}
HTTP/1.1 201 Created
Content-Length: 72
Content-Type: application/json;charset=UTF-8
{"id":"f67ff566-4921-44e2-a9fe-d95f04a0a936","name":"cart 1","items":[]}
GET /api/v1/carts/695f20a8-baa5-4722-965b-9a5085fcb120 HTTP/1.1
Host: localhost:8080
HTTP/1.1 200 OK
Content-Length: 75
Content-Type: application/json;charset=UTF-8
{"id":"695f20a8-baa5-4722-965b-9a5085fcb120","name":"some name","items":[]}
POST /api/v1/carts/5ac1d550-6bae-4fd1-a391-8c4e9826c5e6/items HTTP/1.1
Content-Length: 17
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
{"name":"item 2"}
HTTP/1.1 201 Created
Content-Length: 61
Content-Type: application/json;charset=UTF-8
{"id":"e966e20e-9fe4-43bf-9eba-cdd7156d0196","name":"item 2"}
-
Make
RedisCartRepository
a cache, and use a proper persistence based repository (e.g. a cart repository based on PostgreSQL). As that should be transparent toRedisService
, I’d makeRedisCartRepository
use a decorator pattern to hide the fact that it acts as a cache from its consumers. -
Provide
DELETE
functionality, specifically for items added in a cart. -
Clean-up configuration: Right now
RedisCartRepository
is injected if aREDIS_URL
environment variable is present. That clearly should be moved to configuration files (i.e.application.properties
file).