Search in sources :

Example 41 with ContentType

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

the class ApplicationInfoServiceImplTest method mockContentTypes.

private void mockContentTypes(final ApplicationKey applicationKey) {
    final ContentType contentType = ContentType.create().name(ContentTypeName.media()).form(Form.create().build()).setAbstract().setFinal().allowChildContent(true).setBuiltIn().displayNameExpression("displayNameExpression").displayName("displayName").description("description").modifiedTime(Instant.ofEpochSecond(1000)).createdTime(Instant.ofEpochSecond(1000)).creator(PrincipalKey.ofAnonymous()).modifier(PrincipalKey.ofAnonymous()).build();
    final ContentTypes contentTypes = ContentTypes.from(contentType);
    Mockito.when(this.contentTypeService.getByApplication(applicationKey)).thenReturn(contentTypes);
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType) ContentTypes(com.enonic.xp.schema.content.ContentTypes)

Example 42 with ContentType

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

the class UpdateContentCommand method processContent.

private Content processContent(final Content originalContent, Content editedContent) {
    final ContentType contentType = this.contentTypeService.getByName(GetContentTypeParams.from(editedContent.getType()));
    editedContent = runContentProcessors(originalContent, editedContent, contentType);
    return editedContent;
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType)

Example 43 with ContentType

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

the class ValidateContentDataCommand method execute.

ValidationErrors execute() {
    final ContentType contentType = contentTypeService.getByName(new GetContentTypeParams().contentTypeName(contentTypeName));
    Preconditions.checkArgument(contentType != null, "ContentType [%s] not found", contentTypeName);
    final ContentValidatorParams validatorParams = contentValidatorParamsBuilder.contentType(contentType).build();
    for (ContentValidator contentValidator : contentValidators) {
        if (contentValidator.supports(contentTypeName)) {
            contentValidator.validate(validatorParams, resultBuilder);
        }
    }
    return this.resultBuilder.build();
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ContentValidatorParams(com.enonic.xp.content.ContentValidatorParams) ContentValidator(com.enonic.xp.content.ContentValidator) ContentType(com.enonic.xp.schema.content.ContentType)

Example 44 with ContentType

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

the class RenameContentCommandTest method setUp.

@BeforeEach
void setUp() {
    this.contentTypeService = mock(ContentTypeService.class);
    this.contentService = mock(ContentService.class);
    this.nodeService = mock(NodeService.class);
    this.eventPublisher = mock(EventPublisher.class);
    this.translator = mock(ContentNodeTranslator.class);
    this.xDataService = mock(XDataService.class);
    this.pageDescriptorService = mock(PageDescriptorService.class);
    this.partDescriptorService = mock(PartDescriptorService.class);
    this.layoutDescriptorService = mock(LayoutDescriptorService.class);
    this.contentDataSerializer = ContentDataSerializer.create().layoutDescriptorService(layoutDescriptorService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).build();
    final ContentType contentType = ContentType.create().superType(ContentTypeName.documentMedia()).name(ContentTypeName.dataMedia()).build();
    when(contentTypeService.getByName(isA(GetContentTypeParams.class))).thenReturn(contentType);
    mockNode = Node.create().id(NodeId.from("testId")).build();
    when(nodeService.rename(isA(RenameNodeParams.class))).thenReturn(mockNode);
    when(nodeService.getById(mockNode.id())).thenReturn(mockNode);
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) EventPublisher(com.enonic.xp.event.EventPublisher) ContentType(com.enonic.xp.schema.content.ContentType) NodeService(com.enonic.xp.node.NodeService) XDataService(com.enonic.xp.schema.xdata.XDataService) RenameNodeParams(com.enonic.xp.node.RenameNodeParams) ContentService(com.enonic.xp.content.ContentService) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 45 with ContentType

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

the class ValidateContentDataCommandTest method testSiteConfigTextRegexpFailure.

@Test
public void testSiteConfigTextRegexpFailure() {
    final ContentType contentType = ContentType.create().superType(ContentTypeName.structured()).name(ContentTypeName.site()).build();
    Mockito.when(contentTypeService.getByName(Mockito.isA(GetContentTypeParams.class))).thenReturn(contentType);
    PropertyTree rootDataSet = new PropertyTree();
    PropertyTree siteConfigDataSet = new PropertyTree();
    siteConfigDataSet.setString("textInput-1", "test");
    SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapp")).config(siteConfigDataSet).build();
    new SiteConfigsDataSerializer().toProperties(SiteConfigs.from(siteConfig), rootDataSet.getRoot());
    Mockito.when(siteService.getDescriptor(Mockito.isA(ApplicationKey.class))).thenReturn(createSiteDescriptor());
    // exercise
    final ValidationErrors result = executeValidation(rootDataSet, ContentTypeName.site());
    assertThat(result.stream()).hasSize(1);
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) ApplicationKey(com.enonic.xp.app.ApplicationKey) ContentType(com.enonic.xp.schema.content.ContentType) SiteConfigsDataSerializer(com.enonic.xp.site.SiteConfigsDataSerializer) ValidationErrors(com.enonic.xp.content.ValidationErrors) PropertyTree(com.enonic.xp.data.PropertyTree) SiteConfig(com.enonic.xp.site.SiteConfig) Test(org.junit.jupiter.api.Test)

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