#java #junit #junit4
#java #junit #junit4
Вопрос:
Я новичок в JUnit, я застрял с сообщением об ошибке:
java.lang.Ошибка утверждения:
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:
Вы должны вызвать replay для своих макетов.
EasyMock.replay(inquiryRequest, objectFactory, guarnteecontrol, webServiceESBSupport, inquiryServiceControl);