Package org.springside.examples.showcase.rs.dto

Examples of org.springside.examples.showcase.rs.dto.UserDTO


  @Test
  public void getAllUser() {
    List<UserDTO> userList = client.getAllUser();
    assertTrue(userList.size() >= 6);
    UserDTO admin = userList.iterator().next();
    assertEquals("admin", admin.getLoginName());
  }
View Full Code Here


    assertEquals("<div>Admin, your mother call you...</div>", html);
  }

  @Test
  public void searchUserJson() throws Exception {
    UserDTO admin = client.searchUserJson("Admin");
    assertEquals("admin", admin.getLoginName());
  }
View Full Code Here

  @Path("{id}")
  @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + CHARSET })
  public UserDTO getUser(@PathParam("id") String id) {
    try {
      User entity = accountManager.getInitedUser(id);
      UserDTO dto = dozer.map(entity, UserDTO.class);
      return dto;
    } catch (ObjectNotFoundException e) {
      String message = "用户不存在(id:" + id + ")";
      logger.error(message, e);
      throw buildException(Status.NOT_FOUND, message);
View Full Code Here

        //返回html格式的特定字符串.
        String html = "<div>" + entity.getName() + ", your mother call you...</div>";
        return Response.ok(html, MediaType.TEXT_HTML + CHARSET).build();
      } else {
        //返回JSON格式的对象.
        UserDTO dto = dozer.map(entity, UserDTO.class);
        return Response.ok(dto, MediaType.APPLICATION_JSON).build();
      }
    } catch (ObjectNotFoundException e) {
      String message = "用户不存在(name:" + name + ")";
      logger.error(message, e);
View Full Code Here

  public UserDTO searchUserJson(String name) throws IOException {
    String json = client.path("/users/search").queryParam("name", name).get(String.class);
    ObjectMapper mapper = new ObjectMapper();

    try {
      UserDTO user = mapper.readValue(json, UserDTO.class);
      return user;
    } catch (JsonParseException e) {
      logger.error("JSON response error:" + json, e);
    } catch (JsonMappingException e) {
      logger.error("JSON response error:" + json, e);
View Full Code Here

TOP

Related Classes of org.springside.examples.showcase.rs.dto.UserDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.