java.lang.AssertionError:意外的方法调用InquiryRequest.getPIN():

时间:2014-06-16 07:09:06

标签: java junit junit4

我是JUnit的新手,我遇到了错误信息:

  

java.lang.AssertionError:

  Unexpected method call InquiryRequest.getPIN():
  at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:44)
  at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:85)

如果有任何问题,有人可以告诉我......

    ParticipantSummary summary = new ParticipantSummary();
    EasyMock.expect( inquiryRequest.getPIN() ).andReturn( "1060720" ).anyTimes();
    DateFormat dateFormat = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" );
    Date date = new Date();
    EasyMock.expect( inquiryRequest.getTradeDate() ).andReturn( date ).anyTimes();
    EasyMock.expect( objectFactory.createRetrieveRetirementVintages() ).andReturn( rtvint );
    EasyMock.expect( guarnteecontrol.prepareServiceRequest( inquiryRequest ) ).andReturn( rtvint );
    //      EasyMock.expectLastCall();
    EasyMock.expect( objectFactory.createRetrieveRetirementVintages() ).andReturn( rtvint );

    EasyMock.expect( webServiceESBSupport.jaxbESBSendAndReceive( EasyMock.isA( String.class ), EasyMock.anyObject(), EasyMock.isA( String.class ) ) ).andReturn( retrieveRetirementVintagesResponse ).anyTimes();

    EasyMock.expect( inquiryServiceControl.retrieveRetirementVintages( rtvint ) ).andReturn( retrieveRetirementVintagesResponse );

    ParticipantSummary participantSummary = guarnteecontrol.retrieveAccumulationByVintageSummary( inquiryRequest ); //EasyMock.expectLastCall(); ems.replayAll();

    Assert.assertNotNull( participantSummary );
    //Assert.assertEquals( summary, participantSummary );
}

prepareServiceRequest方法

org.tiaa.transact.generated.jaxb.inquiry.ObjectFactory objectFactory = new org.tiaa.transact.generated.jaxb.inquiry.ObjectFactory();
        org.tiaa.transact.generated.jaxb.inquiry.RetrieveRetirementVintages retirementVintages = objectFactory.createRetrieveRetirementVintages();

        if( ( inquiryRequest ) != null )
        {
            if( ( inquiryRequest.getPIN() ) != null )
            {
                retirementVintages.setPIN( inquiryRequest.getPIN() );
            }
            if( ( inquiryRequest.getTradeDate() != null ) )
            {
                Calendar cal = new GregorianCalendar(); //retirementVintages.setTradeDate(
                TPDateUtil.convertDatetoXMLGregorianCalendar( inquiryRequest.getTradeDate() );
                //retirementVintages.setTradeDate(( inquiryRequest.getTradeDate() );
            }
        }

1 个答案:

答案 0 :(得分:0)

你必须为你的模拟调用重播。

EasyMock.replay(inquiryRequest, objectFactory, guarnteecontrol, webServiceESBSupport, inquiryServiceControl);