DawgPoundRestController { @RequestMapping(value = "reserved/id/{id}", method = RequestMethod.GET) @ResponseBody public Map<String, String> isReservered(@PathVariable String id) { id = clean(id); LOGGER.info("Request to check reservation for id="+id); return service.isReserved(id); }  @RequestMapping(value = "reserved/token/{token}", method = RequestMethod.GET) @ResponseBody Map<String,Object>[] getReservered(@PathVariable String token); @RequestMapping(value = "unreserve/{id}", method = RequestMethod.POST) @ResponseBody String unreserve(@PathVariable String id); @RequestMapping(value = "reserve/{token}/{id}/{expiration}", method = RequestMethod.POST) @ResponseBody String reservePolitely(@PathVariable String token,
            @PathVariable String id, @PathVariable String expiration); @RequestMapping(value = "reserve/override/{token}/{id}/{expiration}", method = RequestMethod.POST) @ResponseBody boolean reserve(@PathVariable String token, @PathVariable String id,
            @PathVariable String expiration); @RequestMapping(value = "reserved/id/{id}", method = RequestMethod.GET) @ResponseBody Map<String, String> isReservered(@PathVariable String id); @RequestMapping(value = "list", method = RequestMethod.GET) @ResponseBody Map<String,Object>[] listAll();  }
@Test public void testIsReserved() { ServerUtils serverUtil = new ServerUtils(); DawgPoundMongoService poundService = EasyMock.createMock(DawgPoundMongoService.class); DawgPoundRestController poundController = new DawgPoundRestController(); ReflectionTestUtils.setField(poundController, "serverUtils", serverUtil); ReflectionTestUtils.setField(poundController, "service", poundService); long expirationTime = System.currentTimeMillis() + TestConstants.ONE_DAY_IN_MILLIS; Map<String, String> reserveMapForDevice = new HashMap<String, String>(); reserveMapForDevice.put("reserver", TestConstants.PROCESSED_TOKEN); reserveMapForDevice.put("expiration", String.valueOf(expirationTime)); EasyMock.expect(poundService.isReserved(TestConstants.DEVICE_ID)).andReturn(reserveMapForDevice); EasyMock.replay(poundService); Map<String, String> reserveList = poundController.isReservered(TestConstants.ORIG_DEVICE_ID); Assert.assertEquals(reserveList.size(), 2); Assert.assertEquals(reserveList.get("reserver"), TestConstants.PROCESSED_TOKEN); Assert.assertEquals(reserveList.get("expiration"), String.valueOf(expirationTime)); EasyMock.verify(poundService); }