title: Basic JUNIT testing. I am getting java.lang.AssertionError
body: <p>I am new to JUNIT testing but tried a lot to test the class UserProfileService. Please help or suggest possible errors I am doing:</p>
  
  <pre><code>@Path("/update")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response updateProfile(final PartyProfile partyProfile) {
      final ProxyResponse response = new ProxyResponse();
      try {
          final boolean isUpdated = partyProfileDao.updateProfile(partyProfile);
          if (isUpdated) {
              LOGGER.info("update Request completed successfully");
              setSuccessResponse(response, "Request completed successfully");
              try{
              final String trailId = partyProfileDao.fetchPartyTrial(partyProfile.getPartyId());
              activityPush(trailId, partyProfile.getPartyId());
              }catch(Exception ex){
                  ex.printStackTrace();
                  LOGGER.error("Exception while triggering segmentation++");
              }
          } else {
              LOGGER.info("Unable to update profile");
              setErrorResponse(response, "PRFUPDT500", "Unable to update profile");
              return Response.ok(response).header("valid", FLAG_FALSE).build();
          }
  
  
  
  
      } catch (Exception exc) {
          LOGGER.error("Unable to update profile:" + exc.getMessage());
          setInternalErrorResponse(exc, response, "Unable to update profile");
          return Response.ok(response).header("valid", FLAG_FALSE).build();
      }
      return Response.ok(response).build();
  }
  </code></pre>
  
  <p>I have written following JUNIT test:</p>
  
  <pre><code>public class PartyProfileServiceTest {
  
  private PartyProfileDAO partyDAO;
  private PartyProfileService partyService;
  
  @Before
  public void setUp() throws Exception {
  
      partyDAO = EasyMock.createMock(PartyProfileDAO.class);
      partyService = EasyMock.createMock(PartyProfileService.class);
      partyService.setUserProfileDAO(partyDAO);
  }
  
  @Test
  public void testUpdateValidProfile() throws Exception {
      System.out.println("inside junit");
  
      PartyProfile partyProfile = new PartyProfile();
  
      partyProfile.setFirstName("adsfsdfg");
      partyProfile.setAddress("adressabc");
      partyProfile.setPartyId("dfdf");
      partyProfile.getSalutation();
      partyProfile.setMiddleName("asfsaf");
      partyProfile.setLastName("easdsddff");
      partyProfile.setNickName("srb");
      partyProfile.setGender("m");
      partyProfile.setUpdateDate("sdd");
      partyProfile.setEducation("srg");
      partyProfile.setInsurance("sg");
      partyProfile.setState("sdfg");
      partyProfile.setSiteId("fdg");
      partyProfile.setRandomNo("feddg");
      partyProfile.setPartyId("56666");
  
  
      EasyMock.expect(partyDAO.updateProfile(partyProfile)).andReturn(true);
      EasyMock.expect(partyDAO.fetchPartyTrial("validPartyId")).andReturn("pass");
      EasyMock.replay(partyDAO);
      EasyMock.expect(partyService.activityPush("pass", "validPartyId")).andReturn(true);
      EasyMock.replay(partyService);
  
      Response response = partyService.updateProfile(partyProfile);
  
      ProxyResponse proxyResponse = (ProxyResponse) response.getEntity();
      Assert.assertSame("Unable to update profile", proxyResponse.getData().get("message"));
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Error:</p>
  
  <pre><code>java.lang.AssertionError: 
  Unexpected method call      PartyProfileService.updateProfile(com.cts.vcoach.proxy.model.PartyProfile@11e170c):
  PartyProfileService.setUserProfileDAO(EasyMock for class com.cts.vcoach.proxy.dao.PartyProfileDAO): expected: 1, actual: 0
  PartyProfileService.activityPush("pass", "validPartyId"): expected: 1, actual: 0
  at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:44)
  at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:94)
  at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:97)
  at com.cts.vcoach.proxy.service.rest.PartyProfileService$$EnhancerByCGLIB$$46a1112f.updateProfile(&lt;generated&gt;)
  at com.cts.vcoach.proxy.service.rest.PartyProfileServiceTest.testUpdateValidProfile(PartyProfileServiceTest.java:59)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
  at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
  at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
  at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>