在我的ATG Droplet中,我正在从存储库中获取记录。现在,当我试图模拟RQLStatement
时,它会抛出一个org.mockito.exceptions.misusing.MissingMethodInvocationException
以下是我试图模仿的陈述:
final RepositoryView view = this.getRepository().getView("product");
final RqlStatement statement = RqlStatement.parseRqlStatement("id = ?0");
prodItems = statement.executeQuery(view, params);
我使用了mockito和powermockito,但它不工作
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]);
添加@PrepareForTest注释。现在为我工作