コード例 #1
0
 @Test
 public void updatingUser() {
   Role role = new Role("admin", "asdas, dfasd");
   User user =
       new User(
           "demon13.by",
           Password.hashPassword(Password.hashPassword("Scorpion") + Password.SALT),
           "Denis",
           "Kravchenko",
           role);
   Report report = new Report(null, new Date(), 56, 12, user);
   List<Report> reports = new ArrayList<Report>();
   reports.add(report);
   Task task = new Task(null, "asdasdasd", "asdasd", 56, "asas", new Date(), user);
   task.setReports(reports);
   TaskDAOImpl taskDao = new TaskDAOImpl();
   taskDao.addTask(task);
   log.fatal(task);
   Integer id = task.getId();
   task.setText("fjghkl");
   taskDao.addTask(task);
   log.fatal(task);
   Task newTask = taskDao.getTask(id);
   log.fatal(newTask);
   assertEquals(task, newTask);
   RoleDAOImpl roleDao = new RoleDAOImpl();
   roleDao.removeRole(role);
 }
コード例 #2
0
 @Test
 public void removingUser() {
   Role role = new Role("admin", "asdas, dfasd");
   RoleDAOImpl roleDao = new RoleDAOImpl();
   roleDao.addRole(role);
   User user =
       new User(
           "demon13.by",
           Password.hashPassword(Password.hashPassword("Scorpion") + Password.SALT),
           "Denis",
           "Kravchenko",
           role);
   UserDAOImpl userDao = new UserDAOImpl();
   userDao.addUser(user);
   Report report = new Report(null, new Date(), 56, 12, user);
   ReportDAOImpl reportDao = new ReportDAOImpl();
   reportDao.addReport(report);
   List<Report> reports = new ArrayList<Report>();
   reports.add(report);
   Task task = new Task(null, "asdasdasd", "asdasd", 56, "asas", new Date(), user);
   TaskDAOImpl taskDao = new TaskDAOImpl();
   taskDao.addTask(task);
   Integer id = task.getId();
   taskDao.removeTask(task);
   Task newTask = taskDao.getTask(id);
   assertNull(newTask);
   roleDao.removeRole(role);
 }