Search in sources :

Example 6 with ContentTypeService

use of com.enonic.xp.schema.content.ContentTypeService 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 7 with ContentTypeService

use of com.enonic.xp.schema.content.ContentTypeService in project xp by enonic.

the class ContentServiceImplTest_isValidContent method test_valid_and_invalid_contents_return_false.

@Test
public void test_valid_and_invalid_contents_return_false() throws Exception {
    final ContentTypeService contentTypeService = Mockito.mock(ContentTypeService.class);
    this.contentService.setContentTypeService(contentTypeService);
    Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(ContentType.create().superType(ContentTypeName.documentMedia()).name("myContentType").addFormItem(Input.create().label("double").name("Double").required(true).inputType(InputTypeName.DOUBLE).build()).build());
    PropertyTree data = new PropertyTree();
    final Content content = this.contentService.create(CreateContentParams.create().type(ContentTypeName.from("myContentType")).contentData(data).requireValid(false).parent(ContentPath.ROOT).displayName("my display-name").build());
    final Content content2 = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
    assertFalse(this.contentService.isValidContent(ContentIds.from(content.getId(), content2.getId())));
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) Test(org.junit.jupiter.api.Test)

Example 8 with ContentTypeService

use of com.enonic.xp.schema.content.ContentTypeService in project xp by enonic.

the class ContentServiceImplTest_isValidContent method test_invalid_content.

@Test
public void test_invalid_content() throws Exception {
    final ContentTypeService contentTypeService = Mockito.mock(ContentTypeService.class);
    this.contentService.setContentTypeService(contentTypeService);
    Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(ContentType.create().superType(ContentTypeName.documentMedia()).name("myContentType").addFormItem(Input.create().label("double").name("Double").required(true).inputType(InputTypeName.DOUBLE).build()).build());
    PropertyTree data = new PropertyTree();
    final Content content = this.contentService.create(CreateContentParams.create().type(ContentTypeName.from("myContentType")).contentData(data).requireValid(false).parent(ContentPath.ROOT).displayName("my display-name").build());
    assertFalse(this.contentService.isValidContent(ContentIds.from(content.getId())));
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) Test(org.junit.jupiter.api.Test)

Example 9 with ContentTypeService

use of com.enonic.xp.schema.content.ContentTypeService in project xp by enonic.

the class ContentServiceImplTest_getInvalidContent method test_valid_and_invalid_contents_return_false.

@Test
public void test_valid_and_invalid_contents_return_false() throws Exception {
    final ContentTypeService contentTypeService = Mockito.mock(ContentTypeService.class);
    this.contentService.setContentTypeService(contentTypeService);
    Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(ContentType.create().superType(ContentTypeName.documentMedia()).name("myContentType").addFormItem(Input.create().label("double").name("Double").required(true).inputType(InputTypeName.DOUBLE).build()).build());
    PropertyTree data = new PropertyTree();
    final Content content = this.contentService.create(CreateContentParams.create().type(ContentTypeName.from("myContentType")).contentData(data).requireValid(false).parent(ContentPath.ROOT).displayName("my display-name").build());
    final Content content2 = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build());
    assertFalse(this.contentService.getInvalidContent(ContentIds.from(content.getId(), content2.getId())).isEmpty());
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) Test(org.junit.jupiter.api.Test)

Aggregations

ContentTypeService (com.enonic.xp.schema.content.ContentTypeService)9 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)8 Test (org.junit.jupiter.api.Test)7 Content (com.enonic.xp.content.Content)6 PropertyTree (com.enonic.xp.data.PropertyTree)6 PageDescriptorService (com.enonic.xp.page.PageDescriptorService)2 LayoutDescriptorService (com.enonic.xp.region.LayoutDescriptorService)2 PartDescriptorService (com.enonic.xp.region.PartDescriptorService)2 XDataService (com.enonic.xp.schema.xdata.XDataService)2 SiteService (com.enonic.xp.site.SiteService)2 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)1 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)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 PropertySet (com.enonic.xp.data.PropertySet)1 NodeEditor (com.enonic.xp.node.NodeEditor)1 NodeId (com.enonic.xp.node.NodeId)1 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)1