Search in sources :

Example 31 with ContentType

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

the class SuperTypeValidatorTest method content_type_passes_validation.

@Test
public void content_type_passes_validation() {
    ContentType contentType = ContentType.create().name(ContentTypeName.documentMedia()).superType(ContentTypeName.media()).build();
    final ContentTypeService contentTypeService = Mockito.mock(ContentTypeService.class);
    Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(contentType);
    ContentTypeSuperTypeValidator validator = ContentTypeSuperTypeValidator.create().contentTypeService(contentTypeService).build();
    validator.validate(ContentTypeName.documentMedia(), ContentTypeName.media());
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) Test(org.junit.jupiter.api.Test)

Example 32 with ContentType

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

the class ContentTypeServiceTest method testEmpty.

@Test
public void testEmpty() {
    final ContentTypes types1 = this.service.getAll();
    assertNotNull(types1);
    assertEquals(22, types1.getSize());
    final ContentTypes types2 = this.service.getByApplication(ApplicationKey.from("other"));
    assertNotNull(types2);
    assertEquals(0, types2.getSize());
    final ContentType contentType = service.getByName(new GetContentTypeParams().contentTypeName("other:mytype"));
    assertEquals(null, contentType);
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) ContentTypes(com.enonic.xp.schema.content.ContentTypes) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 33 with ContentType

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

the class ContentTypeServiceTest method testSystemApplication.

@Test
public void testSystemApplication() {
    ContentTypes contentTypes = this.service.getAll();
    assertNotNull(contentTypes);
    assertEquals(22, contentTypes.getSize());
    ContentType contentType = service.getByName(new GetContentTypeParams().contentTypeName(ContentTypeName.folder()));
    assertNotNull(contentType);
    contentTypes = service.getByApplication(ApplicationKey.BASE);
    assertNotNull(contentTypes);
    assertEquals(contentTypes.getSize(), 5);
    contentTypes = service.getByApplication(ApplicationKey.PORTAL);
    assertNotNull(contentTypes);
    assertEquals(contentTypes.getSize(), 4);
    contentTypes = service.getByApplication(ApplicationKey.MEDIA_MOD);
    assertNotNull(contentTypes);
    assertEquals(contentTypes.getSize(), 13);
    contentType = service.getByName(new GetContentTypeParams().contentTypeName(ContentTypeName.site()));
    assertNotNull(contentType);
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) ContentTypes(com.enonic.xp.schema.content.ContentTypes) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 34 with ContentType

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

the class XDataServiceImplTest method testGetByContentType.

@Test
public void testGetByContentType() {
    initializeApps();
    final ContentType contentType = ContentType.create().superType(ContentTypeName.structured()).name("myapp2:address").xData(XDataNames.from("myapp2:address", "myapp2:address1")).build();
    final XDatas xDatas = service.getFromContentType(contentType);
    assertNotNull(xDatas);
    assertEquals(1, xDatas.getSize());
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType) XDatas(com.enonic.xp.schema.xdata.XDatas) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 35 with ContentType

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

the class ContentTypeServiceTest method testApplications.

@Test
public void testApplications() throws Exception {
    initializeApps();
    final ContentTypes types1 = this.service.getAll();
    assertNotNull(types1);
    assertEquals(24, types1.getSize());
    final ContentTypes types2 = this.service.getByApplication(ApplicationKey.from("myapp1"));
    assertNotNull(types2);
    assertEquals(1, types2.getSize());
    final ContentTypes types3 = this.service.getByApplication(ApplicationKey.from("myapp2"));
    assertNotNull(types3);
    assertEquals(1, types3.getSize());
    final ContentType contentType = service.getByName(new GetContentTypeParams().contentTypeName("myapp1:tag"));
    assertNotNull(contentType);
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) ContentTypes(com.enonic.xp.schema.content.ContentTypes) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

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