how to do a unit testing on this method? anyone can help plzz?

    public boolean saveOrUpdateUser(User user) {
        boolean res = false;
        try {
            this.getHibernateTemplate().saveOrUpdate(user);
            res = true;
        } catch (DataAccessException e) {
            res = false;
            this.logger.error("DataAccessException", e);
        }
        return res;
    }

I've done it like this. can someone confirm if it's good?

 public void saveAndUpdateUserTest() {
                  User user =new User ();
                  user.setFirstname("John");
                  user.setLastname("Smith");

                  assertEquals(12,user.getUser_id());
                  assertEquals("John",user.getFirstname());
                  assertEquals("Smith",user.getLastname());
           }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.