private void tryWithContext(String pageName, final Object context, Object... expected)
{
ComponentModelSource modelSource = mockComponentModelSource();
RequestPageCache pageCache = mockRequestPageCache();
ComponentPageElement element = mockComponentPageElement();
ComponentModel model = mockComponentModel();
Page page = mockPage();
expect(modelSource.getPageModel(pageName)).andReturn(model);
expect(model.handlesEvent(EventConstants.PASSIVATE)).andReturn(true);
train_get(pageCache, pageName, page);
train_getRootElement(page, element);
IAnswer answer = new IAnswer()
{
public Object answer() throws Throwable
{
Object[] args = EasyMock.getCurrentArguments();
ComponentEventCallback callback = (ComponentEventCallback) args[2];
return callback.handleResult(context);
}
};
expect(element.triggerEvent(EasyMock.eq(EventConstants.PASSIVATE),
(Object[]) EasyMock.isNull(),
EasyMock.isA(ComponentEventCallback.class))).andAnswer(answer);
replay();