Search in sources :

Example 11 with ContentType

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();
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType) Form(com.enonic.xp.form.Form)

Example 12 with ContentType

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");
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) CreateContentParams(com.enonic.xp.content.CreateContentParams) Test(org.junit.jupiter.api.Test)

Example 13 with ContentType

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");
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) CreateContentParams(com.enonic.xp.content.CreateContentParams) Test(org.junit.jupiter.api.Test)

Example 14 with ContentType

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));
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType) Test(org.junit.jupiter.api.Test)

Example 15 with 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();
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType)

Aggregations

ContentType (com.enonic.xp.schema.content.ContentType)56 Test (org.junit.jupiter.api.Test)35 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)28 Content (com.enonic.xp.content.Content)12 CreateContentParams (com.enonic.xp.content.CreateContentParams)10 ValidationErrors (com.enonic.xp.content.ValidationErrors)9 Form (com.enonic.xp.form.Form)8 PropertyTree (com.enonic.xp.data.PropertyTree)7 Input (com.enonic.xp.form.Input)7 FormItem (com.enonic.xp.form.FormItem)6 FieldSet (com.enonic.xp.form.FieldSet)5 FormItemSet (com.enonic.xp.form.FormItemSet)5 ContentTypes (com.enonic.xp.schema.content.ContentTypes)5 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)4 EditableSite (com.enonic.xp.content.EditableSite)3 PropertySet (com.enonic.xp.data.PropertySet)3 FormOptionSet (com.enonic.xp.form.FormOptionSet)3 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)3 XData (com.enonic.xp.schema.xdata.XData)3 ApplicationKey (com.enonic.xp.app.ApplicationKey)2