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());
}
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);
}
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();
}
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);
}
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();
}
Aggregations