use of com.enonic.xp.schema.content.GetContentTypeParams in project xp by enonic.
the class CreateContentCommandTest method createFolderInPageTemplate_fails.
@Test
public void createFolderInPageTemplate_fails() {
Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenAnswer(a -> BuiltinContentTypesAccessor.getContentType(((GetContentTypeParams) a.getArgument(0)).getContentTypeName()));
initContent(ContentTypeName.pageTemplate(), "template", ContentConstants.CONTENT_ROOT_PATH);
final CreateContentParams params = CreateContentParams.create().type(ContentTypeName.folder()).name("folder").parent(ContentPath.from("/template")).contentData(new PropertyTree()).displayName("displayName").build();
CreateContentCommand command = createContentCommand(params);
assertThrows(IllegalArgumentException.class, command::execute);
}
use of com.enonic.xp.schema.content.GetContentTypeParams 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();
}
use of com.enonic.xp.schema.content.GetContentTypeParams in project xp by enonic.
the class ContentTypeSuperTypeValidator method validate.
public void validate(final ContentTypeName contentTypeName, final ContentTypeName superTypeContentName) {
if (superTypeContentName != null) {
final GetContentTypeParams params = new GetContentTypeParams().contentTypeName(superTypeContentName);
final ContentType superType = contentTypeService.getByName(params);
if (superType == null) {
registerError(new ContentTypeValidationError("superType not found: " + superTypeContentName, contentTypeName));
return;
}
if (superType.isFinal()) {
registerError(new ContentTypeValidationError("Cannot inherit from a final ContentType: " + superType.getName(), contentTypeName));
}
}
}
use of com.enonic.xp.schema.content.GetContentTypeParams in project xp by enonic.
the class XDataConfigProcessorTest method processForms.
private PatternIndexConfigDocument processForms(final Form... forms) {
final XDatas.Builder xDatasBuilder = XDatas.create();
for (int i = 0; i < forms.length; i++) {
xDatasBuilder.add(XData.create().form(forms[i]).name(XDataName.from("appName:localName" + i)).build());
}
final XDatas xDatas = xDatasBuilder.build();
final ContentType contentType = ContentType.create().superType(ContentTypeName.folder()).xData(XDataNames.from(xDatas.getNames())).name("contentType").build();
Mockito.when(contentTypeService.getByName(new GetContentTypeParams().contentTypeName(contentTypeName))).thenReturn(contentType);
Mockito.when(xDataService.getFromContentType(contentType)).thenReturn(xDatasBuilder.build());
final XDataConfigProcessor configProcessor = new XDataConfigProcessor(xDatas);
return configProcessor.processDocument(PatternIndexConfigDocument.create()).build();
}
use of com.enonic.xp.schema.content.GetContentTypeParams 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