@SuppressWarnings("unchecked")
  @Test
  public void testConvertMapString() {

    Map m = new HashMap();
    User u = new User();
    m.put("userId", 1);
    m.put("email", "*****@*****.**");
    m.put("alias", "Jack");

    User u1 = (User) TribusObjectMapping.convert(m, "model.User");
    Assert.assertEquals(1, u1.getUserId());
    Assert.assertEquals("*****@*****.**", u1.getUserEmail());
    Assert.assertEquals("Jack", u1.getUserAlias());
    // fail("Not yet implemented");
  }
Пример #2
0
  public String execute() {
    System.out.println("Login Action");
    User user = userManager.loginUser(userForm);
    if (user != null) {
      session().setAttribute("userid", user.getUserId());
      session().setAttribute("username", user.getUsername());
      if (user.getQualifications() == 1) {
        return SUCCESS;
      } else {
        return "ACTIVE";
      }

    } else {
      return ERROR;
    }
  }
  public void insertValues(User user) {

    try {

      stmt = conn.createStatement();
      String sql =
          "INSERT INTO user values('"
              + user.getUserId()
              + "','"
              + user.getUserEmail()
              + "','"
              + user.getPassword()
              + "','"
              + user.getRole()
              + "')";
      stmt.execute(sql);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }