use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class ContentTypeHandler method inlineMixins.
private ContentType inlineMixins(final ContentType contentType) {
final ContentType.Builder ctInlined = ContentType.create(contentType);
final Form inlinedForm = mixinService.get().inlineFormItems(contentType.getForm());
if (inlinedForm == null) {
return contentType;
}
return ctInlined.form(inlinedForm).build();
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class CreateContentHandlerTest method createContentAutoGenerateNameWithExistingName.
@Test
public void createContentAutoGenerateNameWithExistingName() throws Exception {
when(this.contentService.create(any(CreateContentParams.class))).thenAnswer(mock -> createContent((CreateContentParams) mock.getArguments()[0]));
when(this.contentService.contentExists(Mockito.eq(ContentPath.from("/a/b/my-content")))).thenReturn(true);
when(this.contentService.contentExists(Mockito.eq(ContentPath.from("/a/b/my-content-1")))).thenReturn(true);
when(this.contentService.contentExists(Mockito.eq(ContentPath.from("/a/b/my-content-2")))).thenReturn(true);
final ContentType contentType = ContentType.create().name("test:myContentType").superType(ContentTypeName.structured()).build();
GetContentTypeParams getContentType = GetContentTypeParams.from(ContentTypeName.from("test:myContentType"));
when(this.contentTypeService.getByName(Mockito.eq(getContentType))).thenReturn(contentType);
runFunction("/test/CreateContentHandlerTest.js", "createContentAutoGenerateNameWithExistingName");
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class CreateContentHandlerTest method createContentAutoGenerateName.
@Test
public void createContentAutoGenerateName() throws Exception {
when(this.contentService.create(any(CreateContentParams.class))).thenAnswer(mock -> createContent((CreateContentParams) mock.getArguments()[0]));
final ContentType contentType = ContentType.create().name("test:myContentType").superType(ContentTypeName.structured()).build();
GetContentTypeParams getContentType = GetContentTypeParams.from(ContentTypeName.from("test:myContentType"));
when(this.contentTypeService.getByName(Mockito.eq(getContentType))).thenReturn(contentType);
runFunction("/test/CreateContentHandlerTest.js", "createContentAutoGenerateName");
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class ImageContentProcessorTest method testSupports.
@Test
public void testSupports() {
ContentType contentType = ContentType.create().superType(ContentTypeName.structured()).name(ContentTypeName.imageMedia()).build();
assertTrue(imageContentProcessor.supports(contentType));
contentType = ContentType.create().superType(ContentTypeName.structured()).name(ContentTypeName.media()).build();
assertFalse(imageContentProcessor.supports(contentType));
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class DataConfigProcessorTest method processForm.
private PatternIndexConfigDocument processForm(final Form form) {
final ContentType contentType = ContentType.create().superType(ContentTypeName.folder()).name("typeName").form(form).build();
Mockito.when(contentTypeService.getByName(new GetContentTypeParams().contentTypeName(contentTypeName))).thenReturn(contentType);
final DataConfigProcessor configProcessor = new DataConfigProcessor(getDataForm(contentTypeService, contentTypeName));
return configProcessor.processDocument(PatternIndexConfigDocument.create()).build();
}
Aggregations