Search in sources :

Example 1 with ContentTypes

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

the class ContentTypeHandlerTest method testExampleGetTypes.

@Test
public void testExampleGetTypes() {
    final Form form = getForm();
    Mockito.when(mixinService.inlineFormItems(Mockito.eq(form))).thenReturn(form);
    final ContentTypes contentTypes = testContentTypes();
    Mockito.when(contentTypeService.getAll()).thenReturn(contentTypes);
    runScript("/lib/xp/examples/content/getTypes.js");
}
Also used : Form(com.enonic.xp.form.Form) ContentTypes(com.enonic.xp.schema.content.ContentTypes) Test(org.junit.jupiter.api.Test)

Example 2 with ContentTypes

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

the class ApplicationInfoServiceImplTest method testContentTypes.

@Test
public void testContentTypes() {
    mockContentTypes(this.applicationKey);
    final ContentTypes contentTypes = this.service.getContentTypes(this.applicationKey);
    assertEquals(contentTypes.getSize(), 1);
}
Also used : ContentTypes(com.enonic.xp.schema.content.ContentTypes) Test(org.junit.jupiter.api.Test)

Example 3 with ContentTypes

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

the class BuiltinContentTypesTest method testBuiltin.

@Test
public void testBuiltin() {
    final ContentTypes types = ContentTypes.from(new BuiltinContentTypes().getAll());
    assertEquals(22, types.getSize());
    assertType(types.get(0), "base:unstructured", true);
    assertType(types.get(1), "base:structured", true);
    assertType(types.get(2), "base:folder", true);
    assertType(types.get(3), "base:shortcut", true);
    assertType(types.get(4), "base:media", true);
    assertType(types.get(5), "media:text", true);
    assertType(types.get(6), "media:data", true);
    assertType(types.get(7), "media:audio", true);
    assertType(types.get(8), "media:video", true);
    assertType(types.get(9), "media:image", true);
    assertType(types.get(10), "media:vector", true);
    assertType(types.get(11), "media:archive", true);
    assertType(types.get(12), "media:document", true);
    assertType(types.get(13), "media:spreadsheet", true);
    assertType(types.get(14), "media:presentation", true);
    assertType(types.get(15), "media:code", true);
    assertType(types.get(16), "media:executable", true);
    assertType(types.get(17), "media:unknown", false);
    assertType(types.get(18), "portal:site", true);
    assertType(types.get(19), "portal:template-folder", true);
    assertType(types.get(20), "portal:page-template", true);
    assertType(types.get(21), "portal:fragment", true);
}
Also used : ContentTypes(com.enonic.xp.schema.content.ContentTypes) Test(org.junit.jupiter.api.Test)

Example 4 with ContentTypes

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

the class ApplicationInfoServiceImplTest method mockContentTypes.

private void mockContentTypes(final ApplicationKey applicationKey) {
    final ContentType contentType = ContentType.create().name(ContentTypeName.media()).form(Form.create().build()).setAbstract().setFinal().allowChildContent(true).setBuiltIn().displayNameExpression("displayNameExpression").displayName("displayName").description("description").modifiedTime(Instant.ofEpochSecond(1000)).createdTime(Instant.ofEpochSecond(1000)).creator(PrincipalKey.ofAnonymous()).modifier(PrincipalKey.ofAnonymous()).build();
    final ContentTypes contentTypes = ContentTypes.from(contentType);
    Mockito.when(this.contentTypeService.getByApplication(applicationKey)).thenReturn(contentTypes);
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType) ContentTypes(com.enonic.xp.schema.content.ContentTypes)

Example 5 with ContentTypes

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

the class AbstractCommand method doTransformInlineMixins.

private ContentTypes doTransformInlineMixins(final ContentTypes contentTypes) {
    final ContentTypes.Builder transformedContentTypes = ContentTypes.create();
    for (final ContentType contentType : contentTypes) {
        final Form transformedForm = mixinService.inlineFormItems(contentType.getForm());
        final ContentType transformedCty = ContentType.create(contentType).form(transformedForm).build();
        transformedContentTypes.add(transformedCty);
    }
    return transformedContentTypes.build();
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType) Form(com.enonic.xp.form.Form) ContentTypes(com.enonic.xp.schema.content.ContentTypes)

Aggregations

ContentTypes (com.enonic.xp.schema.content.ContentTypes)9 Test (org.junit.jupiter.api.Test)7 ContentType (com.enonic.xp.schema.content.ContentType)5 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)3 Form (com.enonic.xp.form.Form)3 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)3