title: jUnit Unexpected method call DAO Easymock
body: <p>I am newbie with mock testing.
  I want to test my DAO for users. Here is my code.</p>
  
  <pre><code>private UserService service;
  private UserDAO mockDAO;
  
  @Before
  public void setUp(){
      service=new UserService();
      mockDAO=createMock(UserDAO.class);
      service.setUserDao(mockDAO);
  }
  
  @Test
  public void testAddUser(){
  
      mockDAO.addUser( (User) EasyMock.anyObject());
      EasyMock.replay(mockDAO);
      User u=new User();
      u.setUserName("x");
      u.setPass("y");
      service.registration(u);
      EasyMock.verify(mockDAO);
  
  }
  </code></pre>
  
  <p>When I run it I get this error:</p>
  
  <p>Updated the stacktrace:</p>
  
  <pre><code>  java.lang.AssertionError: 
    Unexpected method call  UserDAO.checkUser(si.soa.rentacar.model.User@3655dba1):
    UserDao.addUser(&lt;any&gt;): expected: 1, actual: 0
  at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:44)
  at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:85)
  at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:94)
  at si.soa.rentacar.dao.UserDAO$$EnhancerByCGLIB$$1a06d4a9.checkUser(&lt;generated&gt;)
  at si.soa.rentacar.ws.impl.UserService.registration(UserService.java:117)
  at si.soa.rentacar._testUser.testAddUser(_testUser.java:58)
       ....
  </code></pre>