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