use of org.apache.tapestry5.services.LinkCreationListener2 in project tapestry-5 by apache.
the class LinkSourceImplTest method testEventLinkCreation.
private void testEventLinkCreation(String pageName, String nestedId, String eventType, boolean forForm, Object... context) {
Page primaryPage = mockPage();
PageRenderQueue queue = mockPageRenderQueue();
PageActivationContextCollector collector = mockPageActivationContextCollector();
LinkCreationListener2 listener = mockLinkCreationListener2();
ComponentEventLinkEncoder linkEncoder = mockComponentEventLinkEncoder();
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(linkEncoder.createComponentEventLink(parameters, forForm)).andReturn(link);
listener.createdComponentEventLink(link, parameters);
replay();
LinkSource source = new LinkSourceImpl(queue, collector, typeCoercer, null, linkEncoder, null, null, emptyConfiguration);
source.getLinkCreationHub().addListener(listener);
Link returnedLink = source.createComponentEventLink(primaryPage, nestedId, eventType, forForm, context);
// Make sure the same link is returned.
assertSame(returnedLink, link);
verify();
}
Aggregations