I'm New to Junit and am stuck on an issue. Any help would be really appreciated.
public void testGuaranteedRates() throws Exception
{
ParticipantSummary summary = new ParticipantSummary();
EasyMock.expect( iRequest.getPIN() ).andReturn( "1060720" );
DateFormat dateFormat = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" );
Date date = new Date();
EasyMock.expect( iRequest.getTradeDate() ).andReturn( date ).anyTimes();
EasyMock.expect( control.prepareServiceRequest( iRequest ) ).andReturn( rtvint );
EasyMock.replay();
ems.replayAll();
}
The method prepareServiceRequest() is as below
org.tiaa.transact.generated.jaxb.inquiry.RetrieveRetirementVintages prepareServiceRequest(InquiryRequest inquiryRequest)
{
logger.debug( "prepareServiceRequest enter" );
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() );
}
}
logger.debug( "prepareServiceRequest exit" );
return retirementVintages;
}
When i tried to test it , I'm getting an error as below
java.lang.IllegalStateException: missing behavior definition for the preceding method call:
InquiryRequest.getPIN()
Could anyone please let me know if anything is wrong here.
Assuming that iRequest
and control
are mock objects, you need to replay them.
So, instead of:
EasyMock.replay();
try this:
EasyMock.replay(iRequest);
EasyMock.replay(control);