ComponentInstanceResultProcessor implements ComponentEventResultProcessor<Component> { public void processResultValue(Component value) throws IOException { ComponentResources resources = value.getComponentResources(); if (resources.getContainer() != null) { logger.warn("Component {} was returned from an event handler method, but is not a page component. The page containing the component will render the client response.", value.getComponentResources().getCompleteId()); } resultProcessor.processResultValue(resources.getPageName()); } ComponentInstanceResultProcessor(Logger logger,
                                            @Traditional @Primary ComponentEventResultProcessor resultProcessor); void processResultValue(Component value);  }
@Test public void result_is_root_component() throws Exception { Component result = mockComponent(); ComponentResources resources = mockComponentResources(); Logger logger = mockLogger(); ComponentEventResultProcessor primary = mockComponentEventResultProcessor(); train_getComponentResources(result, resources); train_getContainer(resources, null); train_getPageName(resources, PAGE_NAME); primary.processResultValue(PAGE_NAME); replay(); ComponentEventResultProcessor<Component> processor = new ComponentInstanceResultProcessor(logger, primary); processor.processResultValue(result); verify(); }
@Test public void warning_for_component_is_not_root_component() throws Exception { Component value = mockComponent(); Component containerResources = mockComponent(); ComponentResources valueResources = mockComponentResources(); Logger logger = mockLogger(); ComponentEventResultProcessor primary = mockComponentEventResultProcessor(); train_getComponentResources(value, valueResources); train_getContainer(valueResources, containerResources); String completeId = PAGE_NAME + ":child"; train_getCompleteId(valueResources, completeId); logger .warn("Component {} was returned from an event handler method, but is not a page component. The page containing the component will render the client response.", completeId); train_getPageName(valueResources, PAGE_NAME); primary.processResultValue(PAGE_NAME); replay(); ComponentEventResultProcessor<Component> processor = new ComponentInstanceResultProcessor(logger, primary); processor.processResultValue(value); verify(); }