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