### Question:
RedisController { @RequestMapping(value = "/get",method = RequestMethod.GET) public Object get(@RequestParam("id") String id) { Book result = bookService.get(id); JsonResponse response = new JsonResponse(); response.setStatus(true); response.setData(result); return response; }  @RequestMapping(value = "/put",method = RequestMethod.POST) Object add(@RequestBody Book session); @RequestMapping(value = "/get",method = RequestMethod.GET) Object get(@RequestParam("id") String id); @RequestMapping(value = "/evict",method = RequestMethod.GET) Object remove(@RequestParam("id") String id);  }### Answer:
@Test public void when_ObjectIsPutInCache_Then_ReturnObject(){ Map<String,Object> payload = new HashMap(); payload.put("id","XZi32fh8Mn0p"); payload.put("title","DevOps"); payload.put("author","Samuel Addico"); given() .log() .all().contentType("application/json") .body(payload) .when() .post("/put") .then() .statusCode(200) .body("data.id", Matchers.is((String) payload.get("id"))); }
@Test public void when_SessionIdIsParsed_Then_ReturnObjectFromCache(){ String bookId = "Wyi9fh8Mn80p"; given() .log() .all().contentType("application/json") .when() .get("/get?id=" + bookId) .then() .statusCode(200) .body("status", Matchers.is(true)) .body("data.id", Matchers.is(bookId)); }
@Test public void when_ObjectEvicted_Then_RemoveFromCache(){ String bookId = "Wyi9fh8Mn80p"; given() .log() .all().contentType("application/json") .when() .get("/evict?id=" + bookId) .then() .statusCode(200) .body("status", Matchers.is(true)); }