use of com.enonic.xp.schema.content.GetContentTypeParams in project xp by enonic.
the class ContentTypeHandler method getContentType.
public ContentTypeMapper getContentType() {
if (name == null || name.isBlank()) {
return null;
}
final GetContentTypeParams params = GetContentTypeParams.from(ContentTypeName.from(name));
final ContentType ctype = contentTypeService.get().getByName(params);
return ctype == null ? null : new ContentTypeMapper(inlineMixins(ctype));
}
use of com.enonic.xp.schema.content.GetContentTypeParams 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.GetContentTypeParams 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.GetContentTypeParams in project xp by enonic.
the class ContentTypeHandlerTest method testGet.
@Test
public void testGet() throws Exception {
final Form form = getForm();
Mockito.when(mixinService.inlineFormItems(Mockito.eq(form))).thenReturn(form);
final ContentType contentType = testContentType();
final GetContentTypeParams params = new GetContentTypeParams().contentTypeName(contentType.getName());
Mockito.when(contentTypeService.getByName(params)).thenReturn(contentType);
runFunction("/test/ContentTypeHandlerTest.js", "testGet");
}
use of com.enonic.xp.schema.content.GetContentTypeParams in project xp by enonic.
the class ModifyContentHandlerTest method testExample.
@Test
public void testExample() {
GetContentTypeParams getContentType = GetContentTypeParams.from(ContentTypeName.unstructured());
when(this.contentTypeService.getByName(getContentType)).thenReturn(ContentType.create().name(ContentTypeName.unstructured()).setBuiltIn().build());
final Content content = TestDataFixtures.newExampleContent();
when(this.contentService.getByPath(Mockito.any())).thenReturn(content);
when(this.contentService.update(Mockito.isA(UpdateContentParams.class))).thenAnswer(invocationOnMock -> invokeUpdate((UpdateContentParams) invocationOnMock.getArguments()[0], content));
mockXData();
runScript("/lib/xp/examples/content/modify.js");
}
Aggregations