@Test public void testListuser() throws Exception { String ql = new StringBuilder("SELECT COUNT(").append(memberManager.getAliasName()).append(") FROM ") .append(memberManager.getEntityName()).append(" AS ").append(memberManager.getAliasName()) .append(" WHERE ").append(memberManager.getAliasName()).append(".enabled=?1").toString(); int count = memberManager.findUniqueByQL(Long.class, ql, "Y").intValue(); mockMvc.perform(post("/admin/users")).andExpect(request().asyncStarted()) .andExpect(asyncJsonPath("$.total", is(equalTo(count)))).andDo(print()); }
@RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody public Callable<String> listuser() { return new Callable<String>() { @Override public String call() throws Exception { List<Member> users = memberManager.findByCriteria("WHERE enabled=?1 ORDER BY name", "Y"); if (users == null || users.isEmpty()) { return "{\"total\":0,\"users\":[]}"; } else { StringBuilder sb = new StringBuilder("{\"total\":").append(users.size()).append(",\"users\":["); boolean isFirst = true; for (Member user : users) { if (!isFirst) { sb.append(","); } sb.append("{\"account\":\"").append(user.getId()).append("\",\"name\":\"").append(user.getName()) .append("\",\"birthday\":\"").append(String.format("%tF", user.getBirthDay())).append("\"}"); isFirst = false; } sb.append("]}"); return sb.toString(); } } }; }
DefaultController { @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody public Callable<String> listuser() { return new Callable<String>() { @Override public String call() throws Exception { List<Member> users = memberManager.findByCriteria("WHERE enabled=?1 ORDER BY name", "Y"); if (users == null || users.isEmpty()) { return "{\"total\":0,\"users\":[]}"; } else { StringBuilder sb = new StringBuilder("{\"total\":").append(users.size()).append(",\"users\":["); boolean isFirst = true; for (Member user : users) { if (!isFirst) { sb.append(","); } sb.append("{\"account\":\"").append(user.getId()).append("\",\"name\":\"").append(user.getName()) .append("\",\"birthday\":\"").append(String.format("%tF", user.getBirthDay())).append("\"}"); isFirst = false; } sb.append("]}"); return sb.toString(); } } }; } }
DefaultController { @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody public Callable<String> listuser() { return new Callable<String>() { @Override public String call() throws Exception { List<Member> users = memberManager.findByCriteria("WHERE enabled=?1 ORDER BY name", "Y"); if (users == null || users.isEmpty()) { return "{\"total\":0,\"users\":[]}"; } else { StringBuilder sb = new StringBuilder("{\"total\":").append(users.size()).append(",\"users\":["); boolean isFirst = true; for (Member user : users) { if (!isFirst) { sb.append(","); } sb.append("{\"account\":\"").append(user.getId()).append("\",\"name\":\"").append(user.getName()) .append("\",\"birthday\":\"").append(String.format("%tF", user.getBirthDay())).append("\"}"); isFirst = false; } sb.append("]}"); return sb.toString(); } } }; }  }
DefaultController { @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody public Callable<String> listuser() { return new Callable<String>() { @Override public String call() throws Exception { List<Member> users = memberManager.findByCriteria("WHERE enabled=?1 ORDER BY name", "Y"); if (users == null || users.isEmpty()) { return "{\"total\":0,\"users\":[]}"; } else { StringBuilder sb = new StringBuilder("{\"total\":").append(users.size()).append(",\"users\":["); boolean isFirst = true; for (Member user : users) { if (!isFirst) { sb.append(","); } sb.append("{\"account\":\"").append(user.getId()).append("\",\"name\":\"").append(user.getName()) .append("\",\"birthday\":\"").append(String.format("%tF", user.getBirthDay())).append("\"}"); isFirst = false; } sb.append("]}"); return sb.toString(); } } }; }  @InitBinder void initBinder(WebDataBinder binder); @RequestMapping("/") Callable<String> root(final Device device, final Model model); @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody Callable<String> listuser(); @RequestMapping("/user/myinfo") Callable<String> myinfo(final HttpServletRequest request, final Principal principal); @RequestMapping("/admin/user/{account}") Callable<String> userinfo(final @PathVariable Member account, final HttpServletRequest request); }
DefaultController { @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody public Callable<String> listuser() { return new Callable<String>() { @Override public String call() throws Exception { List<Member> users = memberManager.findByCriteria("WHERE enabled=?1 ORDER BY name", "Y"); if (users == null || users.isEmpty()) { return "{\"total\":0,\"users\":[]}"; } else { StringBuilder sb = new StringBuilder("{\"total\":").append(users.size()).append(",\"users\":["); boolean isFirst = true; for (Member user : users) { if (!isFirst) { sb.append(","); } sb.append("{\"account\":\"").append(user.getId()).append("\",\"name\":\"").append(user.getName()) .append("\",\"birthday\":\"").append(String.format("%tF", user.getBirthDay())).append("\"}"); isFirst = false; } sb.append("]}"); return sb.toString(); } } }; }  @InitBinder void initBinder(WebDataBinder binder); @RequestMapping("/") Callable<String> root(final Device device, final Model model); @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody Callable<String> listuser(); @RequestMapping("/user/myinfo") Callable<String> myinfo(final HttpServletRequest request, final Principal principal); @RequestMapping("/admin/user/{account}") Callable<String> userinfo(final @PathVariable Member account, final HttpServletRequest request);  }