Search in sources :

Example 6 with GetContentTypeParams

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);
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 7 with GetContentTypeParams

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();
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType)

Example 8 with GetContentTypeParams

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));
        }
    }
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) ContentTypeValidationError(com.enonic.xp.schema.content.validator.ContentTypeValidationError)

Example 9 with GetContentTypeParams

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();
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentType(com.enonic.xp.schema.content.ContentType) XDatas(com.enonic.xp.schema.xdata.XDatas)

Example 10 with GetContentTypeParams

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

GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)26 ContentType (com.enonic.xp.schema.content.ContentType)18 Test (org.junit.jupiter.api.Test)17 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 PropertyTree (com.enonic.xp.data.PropertyTree)8 Content (com.enonic.xp.content.Content)4 Form (com.enonic.xp.form.Form)4 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)3 ContentTypes (com.enonic.xp.schema.content.ContentTypes)3 ContentAlreadyExistsException (com.enonic.xp.content.ContentAlreadyExistsException)2 FormItemSet (com.enonic.xp.form.FormItemSet)2 Node (com.enonic.xp.node.Node)2 NodePath (com.enonic.xp.node.NodePath)2 XData (com.enonic.xp.schema.xdata.XData)2 ContentAccessException (com.enonic.xp.content.ContentAccessException)1 ContentValidator (com.enonic.xp.content.ContentValidator)1 ContentValidatorParams (com.enonic.xp.content.ContentValidatorParams)1 CreateContentTranslatorParams (com.enonic.xp.content.CreateContentTranslatorParams)1 EditableContent (com.enonic.xp.content.EditableContent)1 MoveContentParams (com.enonic.xp.content.MoveContentParams)1