Question

Inside my ATG Droplet, I am fetching records from repository. Now when I try to mock RQLStatement it throws a org.mockito.exceptions.misusing.MissingMethodInvocationException

Below are the statements I am trying to mock:

 final RepositoryView view = this.getRepository().getView("product");

 final RqlStatement statement = RqlStatement.parseRqlStatement("id = ?0");

 prodItems = statement.executeQuery(view, params);

I used mockito and powermockito but its not working

 PowerMockito.mockStatic(RqlStatement.class);

 PowerMockito.when(RqlStatement.parseRqlStatement("id =?0")).thenReturn(this.statementmock);

 Mockito.when(this.statementmock.executeQuery(this.viewMock, params)).thenReturn(new RepositoryItem[4]);
Was it helpful?

Solution

Adding @PrepareForTest annotation .working for me now

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top