### Question:
ApiCommands { @RequestMapping("/domCount") public JSONObject domCount(HttpServletRequest request) { JSONObject result = new JSONObject(); result.put("count", domainsManager.getDomCount()); return result; }  @RequestMapping("/dom") JSONObject dom(HttpServletRequest request); @RequestMapping("/domCount") JSONObject domCount(HttpServletRequest request); @RequestMapping("/rt4Dom") JSONObject rt4Dom(HttpServletRequest request); @RequestMapping("/ip4Dom2") JSONObject ip4Dom2(HttpServletRequest request); @RequestMapping("/ip4Dom") JSONObject ip4Dom(HttpServletRequest request); @RequestMapping("/regDom") String regDom(HttpServletRequest request); @RequestMapping("/clientBeat") JSONObject clientBeat(HttpServletRequest request); @RequestMapping("/deRegService") String deRegService(HttpServletRequest request); @SuppressFBWarnings("JLM_JSR166_LOCK_MONITORENTER") @RequestMapping("/regService") String regService(HttpServletRequest request); @NeedAuth @RequestMapping("/updateDom") String updateDom(HttpServletRequest request); @RequestMapping("/hello") JSONObject hello(HttpServletRequest request); @NeedAuth @RequestMapping("/remvDom") String remvDom(HttpServletRequest request); @RequestMapping("/getDomsByIP") JSONObject getDomsByIP(HttpServletRequest request); @RequestMapping("/onAddIP4Dom") String onAddIP4Dom(HttpServletRequest request); @NeedAuth @RequestMapping("/addIP4Dom") String addIP4Dom(HttpServletRequest request); @RequestMapping("/srvAllIP") JSONObject srvAllIP(HttpServletRequest request); @RequestMapping("/srvIPXT") @ResponseBody JSONObject srvIPXT(HttpServletRequest request); @NeedAuth @RequestMapping("/remvIP4Dom") String remvIP4Dom(HttpServletRequest request); @RequestMapping("/pushState") JSONObject pushState(HttpServletRequest request); @NeedAuth @RequestMapping("/updateSwitch") String updateSwitch(HttpServletRequest request); @RequestMapping("/checkStatus") JSONObject checkStatus(HttpServletRequest request); void checkIfDisabled(VirtualClusterDomain domObj); @RequestMapping("/switches") JSONObject switches(HttpServletRequest request); @RequestMapping("/getVersion") JSONObject getVersion(HttpServletRequest request); @RequestMapping("/getAllChangeLog") JSONObject getAllChangeLog(HttpServletRequest request); @RequestMapping("/allDomNames") JSONObject allDomNames(HttpServletRequest request); @RequestMapping("/searchDom") JSONObject searchDom(HttpServletRequest request); @RequestMapping("/getWeightsByIP") JSONObject getWeightsByIP(HttpServletRequest request); String doAddCluster4Dom(HttpServletRequest request); @NeedAuth @RequestMapping("/addCluster4Dom") String addCluster4Dom(HttpServletRequest request); @RequestMapping("/distroStatus") JSONObject distroStatus(HttpServletRequest request); @RequestMapping("/metrics") JSONObject metrics(HttpServletRequest request); @RequestMapping("/updateClusterConf") JSONObject updateClusterConf(HttpServletRequest request); @RequestMapping("/serverStatus") String serverStatus(HttpServletRequest request); @RequestMapping("/reCalculateCheckSum4Dom") JSONObject reCalculateCheckSum4Dom(HttpServletRequest request); @RequestMapping("/getDomString4MD5") JSONObject getDomString4MD5(HttpServletRequest request); @RequestMapping("/getResponsibleServer4Dom") JSONObject getResponsibleServer4Dom(HttpServletRequest request); @RequestMapping("/getHealthyServerList") JSONObject getHealthyServerList(HttpServletRequest request); @RequestMapping("/responsible") JSONObject responsible(HttpServletRequest request); @RequestMapping("/domServeStatus") JSONObject domServeStatus(HttpServletRequest request); @RequestMapping("/domStatus") String domStatus(HttpServletRequest request); @RequestMapping("/containerNotify") String containerNotify(HttpServletRequest request); void setDomainsManager(DomainsManager domainsManager);  }### Answer:
@Test public void testDomCount() throws Exception { int mockValue = 5; JSONObject expectedResult = new JSONObject(); expectedResult.put("count", mockValue); Mockito.when(domainsManager.getDomCount()).thenReturn(mockValue); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/naming/api/domCount"); String actualValue = mockmvc.perform(builder).andReturn().getResponse().getContentAsString(); Assert.assertTrue("UnitTest:APICommands.domCount failure!", expectedResult.toString().equals(actualValue)); }