Search in sources :

Example 1 with SiteService

use of com.enonic.xp.site.SiteService in project xp by enonic.

the class ProcessorChainResolverTest method before.

@BeforeEach
public void before() {
    portalRequest = new PortalRequest();
    siteService = Mockito.mock(SiteService.class);
    resolver = new ProcessorChainResolver();
    resolver.setSiteService(siteService);
}
Also used : SiteService(com.enonic.xp.site.SiteService) PortalRequest(com.enonic.xp.portal.PortalRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with SiteService

use of com.enonic.xp.site.SiteService in project xp by enonic.

the class UpdateNodeParamsFactory method toNodeEditor.

private NodeEditor toNodeEditor(final UpdateContentTranslatorParams params) {
    final Content content = params.getEditedContent();
    final PropertyTree nodeData = contentDataSerializer.toUpdateNodeData(params);
    final ContentIndexConfigFactory indexConfigFactory = ContentIndexConfigFactory.create().contentTypeService(contentTypeService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).layoutDescriptorService(layoutDescriptorService).siteService(this.siteService).xDataService(this.xDataService).contentTypeName(content.getType()).page(content.getPage()).siteConfigs(content.isSite() ? ((Site) content).getSiteConfigs() : null).extraDatas(content.getAllExtraData()).language(content.getLanguage() != null ? content.getLanguage().getLanguage() : null).build();
    return editableNode -> {
        editableNode.indexConfigDocument = indexConfigFactory.produce();
        editableNode.data = nodeData;
        editableNode.manualOrderValue = content.getManualOrderValue();
        editableNode.permissions = content.getPermissions();
        editableNode.inheritPermissions = content.inheritsPermissions();
    };
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) SiteService(com.enonic.xp.site.SiteService) Content(com.enonic.xp.content.Content) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) NodeId(com.enonic.xp.node.NodeId) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) Site(com.enonic.xp.site.Site) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ContentDataSerializer(com.enonic.xp.core.impl.content.serializer.ContentDataSerializer) Preconditions(com.google.common.base.Preconditions) ContentIndexConfigFactory(com.enonic.xp.core.impl.content.index.ContentIndexConfigFactory) UpdateContentTranslatorParams(com.enonic.xp.content.UpdateContentTranslatorParams) NodeEditor(com.enonic.xp.node.NodeEditor) XDataService(com.enonic.xp.schema.xdata.XDataService) PropertyTree(com.enonic.xp.data.PropertyTree) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentIndexConfigFactory(com.enonic.xp.core.impl.content.index.ContentIndexConfigFactory)

Example 3 with SiteService

use of com.enonic.xp.site.SiteService in project xp by enonic.

the class HtmlAreaContentProcessorTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    this.siteService = Mockito.mock(SiteService.class);
    this.xDataService = Mockito.mock(XDataService.class);
    this.contentTypeService = Mockito.mock(ContentTypeService.class);
    this.pageDescriptorService = Mockito.mock(PageDescriptorService.class);
    this.partDescriptorService = Mockito.mock(PartDescriptorService.class);
    this.layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
    contentTypeName = ContentTypeName.from("myContentType");
    final GetContentTypeParams params = GetContentTypeParams.from(contentTypeName);
    contentType = ContentType.create().name(contentTypeName).superType(ContentTypeName.folder()).form(Form.create().addFormItem(Input.create().name("htmlData").label("htmlData").inputType(InputTypeName.HTML_AREA).build()).build()).build();
    final ProcessUpdateParams processUpdateParams = ProcessUpdateParams.create().contentType(contentType).build();
    Mockito.when(contentTypeService.getByName(params)).thenReturn(contentType);
    Mockito.when(xDataService.getByNames(Mockito.isA(XDataNames.class))).thenReturn(XDatas.empty());
    htmlAreaContentProcessor = new HtmlAreaContentProcessor();
    htmlAreaContentProcessor.setContentTypeService(contentTypeService);
    htmlAreaContentProcessor.setSiteService(siteService);
    htmlAreaContentProcessor.setXDataService(xDataService);
    htmlAreaContentProcessor.setPageDescriptorService(pageDescriptorService);
    htmlAreaContentProcessor.setPartDescriptorService(partDescriptorService);
    htmlAreaContentProcessor.setLayoutDescriptorService(layoutDescriptorService);
    result = htmlAreaContentProcessor.processUpdate(processUpdateParams);
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) SiteService(com.enonic.xp.site.SiteService) XDataNames(com.enonic.xp.schema.xdata.XDataNames) XDataService(com.enonic.xp.schema.xdata.XDataService) ProcessUpdateParams(com.enonic.xp.content.processor.ProcessUpdateParams) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with SiteService

use of com.enonic.xp.site.SiteService in project xp by enonic.

the class MappingHandlerTest method setup.

@BeforeEach
public final void setup() throws Exception {
    this.request = new PortalRequest();
    final ControllerScriptFactory controllerScriptFactory = mock(ControllerScriptFactory.class);
    ControllerScript controllerScript = mock(ControllerScript.class);
    when(controllerScriptFactory.fromDir(Mockito.any())).thenReturn(controllerScript);
    final PortalResponse portalResponse = PortalResponse.create().build();
    when(controllerScript.execute(Mockito.any())).thenReturn(portalResponse);
    FilterScriptFactory filterScriptFactory = mock(FilterScriptFactory.class);
    FilterScript filterScript = mock(FilterScript.class);
    when(filterScriptFactory.fromScript(Mockito.any())).thenReturn(filterScript);
    when(filterScript.execute(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(portalResponse);
    this.resourceService = mock(ResourceService.class);
    final Resource resourceNotFound = mock(Resource.class);
    when(resourceNotFound.exists()).thenReturn(false);
    final Resource resource = mock(Resource.class);
    when(resource.exists()).thenReturn(true);
    when(this.resourceService.getResource(ResourceKey.from("demo:/services/test"))).thenReturn(resource);
    this.contentService = mock(ContentService.class);
    this.rendererDelegate = mock(RendererDelegate.class);
    this.siteService = mock(SiteService.class);
    this.handler = new MappingHandler(resourceService, controllerScriptFactory, filterScriptFactory, rendererDelegate, new ControllerMappingsResolver(siteService), new ContentResolver(contentService));
    this.request.setMethod(HttpMethod.GET);
}
Also used : FilterScriptFactory(com.enonic.xp.portal.filter.FilterScriptFactory) ControllerScript(com.enonic.xp.portal.controller.ControllerScript) FilterScript(com.enonic.xp.portal.filter.FilterScript) ResourceService(com.enonic.xp.resource.ResourceService) Resource(com.enonic.xp.resource.Resource) ContentService(com.enonic.xp.content.ContentService) ControllerScriptFactory(com.enonic.xp.portal.controller.ControllerScriptFactory) PortalRequest(com.enonic.xp.portal.PortalRequest) ContentResolver(com.enonic.xp.portal.impl.ContentResolver) PortalResponse(com.enonic.xp.portal.PortalResponse) SiteService(com.enonic.xp.site.SiteService) RendererDelegate(com.enonic.xp.portal.impl.rendering.RendererDelegate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SiteService (com.enonic.xp.site.SiteService)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 PageDescriptorService (com.enonic.xp.page.PageDescriptorService)2 PortalRequest (com.enonic.xp.portal.PortalRequest)2 LayoutDescriptorService (com.enonic.xp.region.LayoutDescriptorService)2 PartDescriptorService (com.enonic.xp.region.PartDescriptorService)2 ContentTypeService (com.enonic.xp.schema.content.ContentTypeService)2 XDataService (com.enonic.xp.schema.xdata.XDataService)2 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)1 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)1 Content (com.enonic.xp.content.Content)1 ContentService (com.enonic.xp.content.ContentService)1 UpdateContentTranslatorParams (com.enonic.xp.content.UpdateContentTranslatorParams)1 ProcessUpdateParams (com.enonic.xp.content.processor.ProcessUpdateParams)1 ContentIndexConfigFactory (com.enonic.xp.core.impl.content.index.ContentIndexConfigFactory)1 ContentDataSerializer (com.enonic.xp.core.impl.content.serializer.ContentDataSerializer)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 NodeEditor (com.enonic.xp.node.NodeEditor)1 NodeId (com.enonic.xp.node.NodeId)1 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)1