Page primaryPage = mockPage();
PageRenderQueue queue = mockPageRenderQueue();
PageActivationContextCollector collector = mockPageActivationContextCollector();
LinkCreationListener listener = mockLinkCreationListener();
LinkFactory factory = mockLinkFactory();
Link link = mockLink();
ArrayEventContext eventContext = new ArrayEventContext(typeCoercer, context);
ArrayEventContext pageEventContext = new ArrayEventContext(
typeCoercer, "a", "b");
train_getRenderingPage(queue, null);
train_getName(primaryPage, pageName);
train_collectPageActivationContext(collector, pageName, "a", "b");
ComponentEventRequestParameters parameters =
new ComponentEventRequestParameters(pageName, pageName,
nestedId, eventType,
pageEventContext, eventContext);
expect(factory.createComponentEventLink(parameters, forForm)).andReturn(link);
listener.createdComponentEventLink(link);
replay();
LinkSource source = new LinkSourceImpl(null, queue,
collector, factory, typeCoercer, null);
source.getLinkCreationHub().addListener(listener);
Link returnedLink = source.createComponentEventLink(primaryPage, nestedId, eventType, forForm, context);
// Make sure the same link is returned.
assertSame(returnedLink, link);