LinkSourceImpl implements LinkSource, LinkCreationHub { public Link createPageRenderLink(String pageName, boolean override, Object... pageActivationContext) { String canonical = resolver.canonicalizePageName(pageName); Object[] context = (override || pageActivationContext.length != 0) ? pageActivationContext : contextCollector .collectPageActivationContext(canonical); boolean loopback = canonical.equals(requestGlobals.getActivePageName()) && pageCache.get(pageName).hasResetListeners(); PageRenderRequestParameters parameters = new PageRenderRequestParameters(canonical, new ArrayEventContext( typeCoercer, context), loopback); Link link = linkEncoder.createPageRenderLink(parameters); for (LinkCreationListener2 listener : listeners) listener.createdPageRenderLink(link, parameters); return link; } LinkSourceImpl(PageRenderQueue pageRenderQueue, PageActivationContextCollector contextCollector,
            TypeCoercer typeCoercer, ComponentClassResolver resolver, ComponentEventLinkEncoder linkEncoder,
            RequestGlobals requestGlobals, RequestPageCache pageCache, List<LinkCreationListener2> configuration); Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm,
            Object... eventContext); Link createPageRenderLink(String pageName, boolean override, Object... pageActivationContext); LinkCreationHub getLinkCreationHub(); void addListener(LinkCreationListener listener); void addListener(LinkCreationListener2 listener);  }
@Test public void create_page_render_link_by_name() { String pageName = "order/Edit"; PageActivationContextCollector collector = mockPageActivationContextCollector(); ComponentEventLinkEncoder linkEncoder = mockComponentEventLinkEncoder(); Link link = mockLink(); ComponentClassResolver resolver = mockComponentClassResolver(); RequestGlobals globals = mockRequestGlobals(); expect(globals.getActivePageName()).andReturn("someOtherPage"); train_canonicalizePageName(resolver, pageName, pageName); train_collectPageActivationContext(collector, pageName, 3); EventContext pageActivationContext = new ArrayEventContext(typeCoercer, 3); PageRenderRequestParameters parameters = new PageRenderRequestParameters(pageName, pageActivationContext, false); expect(linkEncoder.createPageRenderLink(parameters)).andReturn(link); replay(); LinkSource source = new LinkSourceImpl(null, collector, typeCoercer, resolver, linkEncoder, globals, null, emptyConfiguration); Link actual = source.createPageRenderLink(pageName, false); assertEquals(actual, link); verify(); }