Search in sources :

Example 1 with LayoutDescriptorService

use of com.enonic.xp.region.LayoutDescriptorService in project xp by enonic.

the class LayoutRendererTest method nullResponseComponentEditMode.

@Test
public void nullResponseComponentEditMode() {
    final LayoutDescriptor layoutDescriptor = LayoutDescriptor.create().displayName("My layout component").config(Form.create().build()).key(DescriptorKey.from("module:myLayoutComponent")).regions(RegionDescriptors.create().add(RegionDescriptor.create().name("left").build()).add(RegionDescriptor.create().name("right").build()).build()).build();
    final ControllerScript controllerScript = new ControllerScript() {

        @Override
        public PortalResponse execute(final PortalRequest portalRequest) {
            return new PortalResponseSerializer(null).serialize();
        }

        @Override
        public void onSocketEvent(final WebSocketEvent event) {
        }
    };
    final LayoutDescriptorService layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
    final ControllerScriptFactory controllerScriptFactory = Mockito.mock(ControllerScriptFactory.class);
    renderer = new LayoutRenderer();
    renderer.setLayoutDescriptorService(layoutDescriptorService);
    renderer.setControllerScriptFactory(controllerScriptFactory);
    when(layoutDescriptorService.getByKey(any())).thenReturn(layoutDescriptor);
    when(controllerScriptFactory.fromDir(any())).thenReturn(controllerScript);
    portalRequest.setMode(RenderMode.EDIT);
    layoutComponent = LayoutComponent.create().descriptor("myapp:myLayoutComponent").descriptor(layoutDescriptor.getKey()).build();
    // exercise
    portalResponse = renderer.render(layoutComponent, portalRequest);
    // verify
    String expected = "<div data-portal-component-type=\"layout\"></div>";
    assertEquals(expected, portalResponse.getAsString());
}
Also used : PortalResponseSerializer(com.enonic.xp.portal.impl.controller.PortalResponseSerializer) WebSocketEvent(com.enonic.xp.web.websocket.WebSocketEvent) LayoutDescriptor(com.enonic.xp.region.LayoutDescriptor) ControllerScript(com.enonic.xp.portal.controller.ControllerScript) ControllerScriptFactory(com.enonic.xp.portal.controller.ControllerScriptFactory) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) PortalRequest(com.enonic.xp.portal.PortalRequest) Test(org.junit.jupiter.api.Test)

Example 2 with LayoutDescriptorService

use of com.enonic.xp.region.LayoutDescriptorService in project xp by enonic.

the class ContentNodeTranslatorTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    this.nodeService = Mockito.mock(NodeService.class);
    final PartDescriptorService partDescriptorService = Mockito.mock(PartDescriptorService.class);
    final LayoutDescriptorService layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
    final PageDescriptorService pageDescriptorService = Mockito.mock(PageDescriptorService.class);
    final ContentDataSerializer contentDataSerializer = ContentDataSerializer.create().layoutDescriptorService(layoutDescriptorService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).build();
    this.contentNodeTranslator = new ContentNodeTranslator(nodeService, contentDataSerializer);
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) ContentDataSerializer(com.enonic.xp.core.impl.content.serializer.ContentDataSerializer) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) NodeService(com.enonic.xp.node.NodeService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with LayoutDescriptorService

use of com.enonic.xp.region.LayoutDescriptorService in project xp by enonic.

the class ImportContentFactoryTest method createContentDataSerializer.

private ContentDataSerializer createContentDataSerializer() {
    final PageDescriptorService pageDescriptorService = Mockito.mock(PageDescriptorService.class);
    final PartDescriptorService partDescriptorService = Mockito.mock(PartDescriptorService.class);
    final LayoutDescriptorService layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
    return ContentDataSerializer.create().partDescriptorService(partDescriptorService).pageDescriptorService(pageDescriptorService).layoutDescriptorService(layoutDescriptorService).build();
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService)

Example 4 with LayoutDescriptorService

use of com.enonic.xp.region.LayoutDescriptorService in project xp by enonic.

the class RenameContentCommandTest method setUp.

@BeforeEach
void setUp() {
    this.contentTypeService = mock(ContentTypeService.class);
    this.contentService = mock(ContentService.class);
    this.nodeService = mock(NodeService.class);
    this.eventPublisher = mock(EventPublisher.class);
    this.translator = mock(ContentNodeTranslator.class);
    this.xDataService = mock(XDataService.class);
    this.pageDescriptorService = mock(PageDescriptorService.class);
    this.partDescriptorService = mock(PartDescriptorService.class);
    this.layoutDescriptorService = mock(LayoutDescriptorService.class);
    this.contentDataSerializer = ContentDataSerializer.create().layoutDescriptorService(layoutDescriptorService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).build();
    final ContentType contentType = ContentType.create().superType(ContentTypeName.documentMedia()).name(ContentTypeName.dataMedia()).build();
    when(contentTypeService.getByName(isA(GetContentTypeParams.class))).thenReturn(contentType);
    mockNode = Node.create().id(NodeId.from("testId")).build();
    when(nodeService.rename(isA(RenameNodeParams.class))).thenReturn(mockNode);
    when(nodeService.getById(mockNode.id())).thenReturn(mockNode);
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) EventPublisher(com.enonic.xp.event.EventPublisher) ContentType(com.enonic.xp.schema.content.ContentType) NodeService(com.enonic.xp.node.NodeService) XDataService(com.enonic.xp.schema.xdata.XDataService) RenameNodeParams(com.enonic.xp.node.RenameNodeParams) ContentService(com.enonic.xp.content.ContentService) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with LayoutDescriptorService

use of com.enonic.xp.region.LayoutDescriptorService in project xp by enonic.

the class ContentDataSerializerTest method createContentDataSerializer.

private ContentDataSerializer createContentDataSerializer() {
    final PageDescriptorService pageDescriptorService = Mockito.mock(PageDescriptorService.class);
    final PartDescriptorService partDescriptorService = Mockito.mock(PartDescriptorService.class);
    final LayoutDescriptorService layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
    return ContentDataSerializer.create().partDescriptorService(partDescriptorService).pageDescriptorService(pageDescriptorService).layoutDescriptorService(layoutDescriptorService).build();
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService)

Aggregations

LayoutDescriptorService (com.enonic.xp.region.LayoutDescriptorService)11 PageDescriptorService (com.enonic.xp.page.PageDescriptorService)9 PartDescriptorService (com.enonic.xp.region.PartDescriptorService)9 XDataService (com.enonic.xp.schema.xdata.XDataService)5 Content (com.enonic.xp.content.Content)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 ContentDataSerializer (com.enonic.xp.core.impl.content.serializer.ContentDataSerializer)3 PropertyTree (com.enonic.xp.data.PropertyTree)3 ContentType (com.enonic.xp.schema.content.ContentType)3 ContentTypeName (com.enonic.xp.schema.content.ContentTypeName)3 ContentTypeService (com.enonic.xp.schema.content.ContentTypeService)3 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)3 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)2 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)2 AuditLogService (com.enonic.xp.audit.AuditLogService)2 ContentConstants (com.enonic.xp.content.ContentConstants)2 ContentInheritType (com.enonic.xp.content.ContentInheritType)2 ContentPath (com.enonic.xp.content.ContentPath)2 ContentPublishInfo (com.enonic.xp.content.ContentPublishInfo)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)2