use of com.enonic.xp.page.PageTemplate in project xp by enonic.
the class CreatePageTemplateCommand method execute.
public PageTemplate execute() {
final PropertyTree data = new PropertyTree();
new PageTemplateFormDataBuilder().supports(supports).appendData(data.getRoot());
final Content content = contentService.create(CreateContentParams.create().name(name).displayName(displayName).owner(PrincipalKey.ofAnonymous()).contentData(data).type(ContentTypeName.pageTemplate()).inheritPermissions(true).parent(ContentPath.from(site, ContentServiceImpl.TEMPLATES_FOLDER_NAME)).build());
return (PageTemplate) pageService.create(new CreatePageParams().content(content.getId()).controller(controller).config(pageConfig).regions(pageRegions));
}
use of com.enonic.xp.page.PageTemplate in project xp by enonic.
the class ComponentInstructionTest method testInstructionRenderFragment.
@Test
public void testInstructionRenderFragment() throws Exception {
RendererDelegate rendererDelegate = newRendererFactory("<b>part content</b>");
ComponentService componentService = Mockito.mock(ComponentService.class);
Component component = createPartComponent();
doReturn(component).when(componentService).getByKey(isA(DescriptorKey.class));
ComponentInstruction instruction = new ComponentInstruction();
instruction.setRendererDelegate(rendererDelegate);
instruction.setComponentService(componentService);
PortalRequest portalRequest = new PortalRequest();
Content content = createFragmentPage("content-id", "content-name");
portalRequest.setContent(content);
Site site = createSite("site-id", "site-name", "myapplication:content-type");
portalRequest.setSite(site);
PageTemplate pageTemplate = createPageTemplate();
portalRequest.setPageTemplate(pageTemplate);
String outputHtml = instruction.evaluate(portalRequest, "COMPONENT fragment").getAsString();
assertEquals("<b>part content</b>", outputHtml);
}
Aggregations