Search in sources :

Example 6 with LinkCreationListener2

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();
}
Also used : ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) ComponentEventRequestParameters(org.apache.tapestry5.services.ComponentEventRequestParameters) Page(org.apache.tapestry5.internal.structure.Page) LinkCreationListener2(org.apache.tapestry5.services.LinkCreationListener2) Link(org.apache.tapestry5.http.Link)

Aggregations

Link (org.apache.tapestry5.http.Link)6 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)6 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)4 Page (org.apache.tapestry5.internal.structure.Page)3 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)3 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)3 RequestGlobals (org.apache.tapestry5.http.services.RequestGlobals)2 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)2