Ejemplo n.º 1
0
  public void testDeleteByName() throws ParseException, UserException {

    UserDAO userDAO = new UserDAO();
    User user =
        new User("Marcelo", "marceloChavosaoa", "*****@*****.**", "123456", "24/11/1969");
    if (!userDAO.save(user).contains("Salvo")) assertTrue(false);
    assertTrue(userDAO.delete("marceloChavosaoa").contains("Salvo"));
  }
Ejemplo n.º 2
0
  public void testDeleteById() throws ParseException, UserException, JSONException {

    UserDAO userDAO = new UserDAO();
    User user = new User("VIny", "viny", "*****@*****.**", "123456", "14/02/1995");
    if (!userDAO.save(user).contains("Salvo")) assertTrue(false);
    int id = userDAO.searchUserByUsername("viny").getJSONObject("0").getInt("idUser");
    assertTrue(userDAO.delete(id).contains("Salvo"));
    userDAO.delete("viny");
  }
Ejemplo n.º 3
0
 public void testSave() throws ParseException, UserException {
   UserDAO userDAO = new UserDAO();
   User user;
   user =
       new User(
           "marceloChavosaao",
           "marceloChavosaao",
           "*****@*****.**",
           "*****@*****.**",
           "123456",
           "123456",
           "11/09/2015");
   assertTrue(userDAO.save(user).contains("Salvo"));
   userDAO.delete("marceloChavosaao");
 }
Ejemplo n.º 4
0
 public void testUpdateUser() throws ParseException, UserException, JSONException {
   UserDAO userDAO = new UserDAO();
   User user =
       new User(
           1,
           "Vinicius ppp",
           "umteste",
           "14/02/1995",
           "*****@*****.**",
           "*****@*****.**",
           "123456",
           "123456");
   if (!userDAO.save(user).contains("Salvo")) {
     assertTrue(false);
     userDAO.delete("umteste");
   }
   assertTrue(userDAO.update(user).contains("Salvo"));
   userDAO.delete("umteste");
 }
Ejemplo n.º 5
0
 public void testDisableLogin() throws ParseException, UserException, JSONException {
   UserDAO userDAO = new UserDAO();
   User user =
       new User(
           1,
           "Vinicius Pinheiro",
           "umteste",
           "14/02/1995",
           "*****@*****.**",
           "*****@*****.**",
           "123456",
           "123456");
   if (!userDAO.save(user).contains("Salvo")) {
     assertTrue(false);
     userDAO.delete("umteste");
   }
   int id = userDAO.searchUserByUsername("umteste").getJSONObject("0").getInt("idUser");
   assertTrue(userDAO.disableUser(id).contains("Salvo"));
   userDAO.delete("umteste");
 }
Ejemplo n.º 6
0
  //    @PostConstruct
  public void init() {

    System.out.println("PostConstruct method call...");

    User ulan = new User();
    ulan.setName("Ulan");

    userDAO.save(ulan);

    User carl = new User("Carl");
    userDAO.save(carl);

    //        System.out.println(ulan);

    List<User> userList = userDAO.getUserList();

    System.out.println("UserList:");

    for (User u : userList) {
      System.out.println(u);
    }

    Loan loan1 = new Loan();
    loan1.setAmount(300);
    loan1.setTerm(15);

    Loan loan2 = new Loan();
    loan2.setAmount(200);
    loan2.setTerm(10);

    Loan loan3 = new Loan();
    loan3.setAmount(400);
    loan3.setTerm(20);

    User user1 = userList.get(0);

    user1.addLoan(loan1);
    user1.addLoan(loan2);

    User user2 = userList.get(1);

    user2.addLoan(loan3);

    userDAO.save(user1);
    userDAO.save(user2);

    List<Loan> loanList = loanDAO.getLoanList();
    System.out.println("Printing loanList:");
    for (Loan loan : loanList) {
      System.out.println(loan);
    }

    System.out.println("Printing whole DB:");
    userList = userDAO.getUserList();
    for (User u : userList) {
      System.out.println(u);
      for (Loan loan : u.getLoanList()) {
        System.out.println(loan);
      }
    }

    System.out.println("Printing list for User with ID 1");
    user1 = userDAO.getById(1);
    for (Loan loan : user1.getLoanList()) {
      System.out.println(loan);
    }

    System.out.println("Printing list for User with ID 2");
    user2 = userDAO.getById(2);
    for (Loan loan : user2.getLoanList()) {
      System.out.println(loan);
    }
  }