如何模拟ATG RqlStatement

时间:2013-08-12 07:38:50

标签: mockito powermock atg

在我的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]);

1 个答案:

答案 0 :(得分:0)

添加@PrepareForTest 注释。现在为我工作