use of com.enonic.xp.site.Site in project xp by enonic.
the class TestDataFixtures method newSite.
public static Site.Builder newSite() {
final PropertyTree siteConfigConfig = new PropertyTree();
siteConfigConfig.setLong("Field", 42L);
final SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapplication")).config(siteConfigConfig).build();
final Site.Builder site = Site.create();
site.id(ContentId.from("100123"));
site.siteConfigs(SiteConfigs.from(siteConfig));
site.name("my-content");
site.parentPath(ContentPath.ROOT);
site.permissions(AccessControlList.of(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()));
return site;
}
use of com.enonic.xp.site.Site in project xp by enonic.
the class GetCurrentSiteConfigScriptTest method testExample.
@Test
public void testExample() {
final Site site = TestDataFixtures.newSite().build();
this.portalRequest.setSite(site);
runScript("/lib/xp/examples/portal/getSiteConfig.js");
}
use of com.enonic.xp.site.Site 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);
}
use of com.enonic.xp.site.Site in project xp by enonic.
the class MacroInstructionTest method setUp.
@BeforeEach
public void setUp() {
macroDescriptorService = Mockito.mock(MacroDescriptorService.class);
macroProcessorFactory = Mockito.mock(MacroProcessorFactory.class);
macroInstruction = new MacroInstruction();
macroInstruction.setMacroDescriptorService(macroDescriptorService);
macroInstruction.setMacroProcessorFactory(macroProcessorFactory);
portalRequest = new PortalRequest();
Site site = createSite("site-id", "site-name", "myapplication:content-type");
portalRequest.setSite(site);
portalRequest.setContent(site);
}
use of com.enonic.xp.site.Site in project xp by enonic.
the class ContentServiceImpl method create.
@Override
public Site create(final CreateSiteParams params) {
final PropertyTree data = new PropertyTree();
data.setString("description", params.getDescription());
SITE_CONFIGS_DATA_SERIALIZER.toProperties(params.getSiteConfigs(), data.getRoot());
final CreateContentParams createContentParams = CreateContentParams.create().type(ContentTypeName.site()).parent(params.getParentContentPath()).name(params.getName()).displayName(params.getDisplayName()).contentData(data).requireValid(params.isRequireValid()).build();
final Site site = (Site) CreateContentCommand.create().nodeService(this.nodeService).contentTypeService(this.contentTypeService).translator(this.translator).eventPublisher(this.eventPublisher).siteService(this.siteService).xDataService(this.xDataService).contentProcessors(this.contentProcessors).contentValidators(this.contentValidators).formDefaultValuesProcessor(this.formDefaultValuesProcessor).pageDescriptorService(this.pageDescriptorService).partDescriptorService(this.partDescriptorService).layoutDescriptorService(this.layoutDescriptorService).contentDataSerializer(this.contentDataSerializer).allowUnsafeAttachmentNames(config.attachments_allowUnsafeNames()).params(createContentParams).build().execute();
this.create(CreateContentParams.create().owner(site.getOwner()).displayName(TEMPLATES_FOLDER_DISPLAY_NAME).name(TEMPLATES_FOLDER_NAME).inheritPermissions(true).parent(site.getPath()).type(ContentTypeName.templateFolder()).requireValid(true).contentData(new PropertyTree()).build());
contentAuditLogSupport.createSite(params, site);
return site;
}
Aggregations