Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

junit test case error

 
ac mohan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
error "java.lang.IllegalStateException: no last call on a mock available" below is the code.

@Test
public void testGetis() {
ServiceProcessResponse response = new ServiceProcessResponse();

response.setStatus("S");
response.setError(null);
ServiceProcessRequest request=new ServiceProcessRequest();
request.setEmailAddress("11");
request.setOrderNumber("123");
expect(DaoImpl.getService().process(
request, null, null)).andReturn(response);
replay(promotionDaoImpl);
DaoImpl.data(anyString(),anyBoolean(), anyBoolean());
verify(DaoImpl);
}
i am getting error at "when" statement line.

can any one help on this please.
 
Immanuel Marimuthu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you be specific in which line you are getting the error ..sorry I am not getting "when" line...?

Anyway my inputs based on the error message..

Please verify the method that you are mocking in your code is actually having a return type instead of being void..

If it a void...then you can use exceptLastCall method of Mock class and then you can have your desired response..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic