Search in sources :

Example 6 with SiteDescriptor

use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.

the class XmlSiteParserTest method testEmptySiteXmlDeserialization.

@Test
public void testEmptySiteXmlDeserialization() {
    final String xml = loadTestXml("empty-site.xml");
    final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
    ApplicationKey applicationKey = ApplicationKey.from("myapplication");
    this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
    SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
    assertEquals(0, siteDescriptor.getForm().getFormItems().size());
    assertEquals(0, siteDescriptor.getXDataMappings().getSize());
    assertEquals(0, siteDescriptor.getResponseProcessors().getSize());
    assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Example 7 with SiteDescriptor

use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.

the class SiteConfigProcessorTest method processConfigs.

private PatternIndexConfigDocument processConfigs(final SiteConfigs siteConfigs, final Form... forms) {
    for (int i = 0; i < siteConfigs.getSize(); i++) {
        final SiteConfig siteConfig = siteConfigs.get(i);
        final SiteDescriptor descriptor = SiteDescriptor.create().form(forms[i]).build();
        Mockito.when(siteService.getDescriptor(siteConfig.getApplicationKey())).thenReturn(descriptor);
    }
    final SiteConfigProcessor configProcessor = new SiteConfigProcessor(getConfigForms(siteService, siteConfigs));
    return configProcessor.processDocument(PatternIndexConfigDocument.create()).build();
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) SiteConfig(com.enonic.xp.site.SiteConfig)

Example 8 with SiteDescriptor

use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.

the class SiteServiceImpl method getDescriptor.

@Override
public SiteDescriptor getDescriptor(final ApplicationKey applicationKey) {
    final ResourceProcessor<ApplicationKey, SiteDescriptor> processor = newProcessor(applicationKey);
    final SiteDescriptor descriptor = this.resourceService.processResource(processor);
    if (descriptor == null) {
        return null;
    }
    final Form form = mixinService.inlineFormItems(descriptor.getForm());
    return SiteDescriptor.copyOf(descriptor).form(form).build();
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) Form(com.enonic.xp.form.Form)

Example 9 with SiteDescriptor

use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.

the class SiteServiceImplTest method get_descriptor_for_unknown_application.

@Test
public void get_descriptor_for_unknown_application() {
    final ApplicationKey applicationKey = ApplicationKey.from("unknown");
    final SiteDescriptor siteDescriptor = this.service.getDescriptor(applicationKey);
    assertEquals(null, siteDescriptor);
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Example 10 with SiteDescriptor

use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.

the class SiteServiceImplTest method get_descriptor.

@Test
public void get_descriptor() throws Exception {
    final ApplicationKey applicationKey = ApplicationKey.from("myapp");
    final SiteDescriptor siteDescriptor = this.service.getDescriptor(applicationKey);
    assertEquals(1, siteDescriptor.getForm().getFormItems().size());
    assertEquals(2, siteDescriptor.getXDataMappings().getSize());
    assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
    assertEquals("filter1", siteDescriptor.getResponseProcessors().get(0).getName());
    assertEquals(20, siteDescriptor.getResponseProcessors().get(1).getOrder());
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Aggregations

SiteDescriptor (com.enonic.xp.site.SiteDescriptor)24 Test (org.junit.jupiter.api.Test)17 ApplicationKey (com.enonic.xp.app.ApplicationKey)13 Content (com.enonic.xp.content.Content)7 ControllerMappingDescriptor (com.enonic.xp.site.mapping.ControllerMappingDescriptor)7 Site (com.enonic.xp.site.Site)6 SiteConfig (com.enonic.xp.site.SiteConfig)4 ControllerMappingDescriptors (com.enonic.xp.site.mapping.ControllerMappingDescriptors)3 EditableContent (com.enonic.xp.content.EditableContent)2 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 Form (com.enonic.xp.form.Form)2 ResponseProcessorDescriptor (com.enonic.xp.site.processor.ResponseProcessorDescriptor)2 ContentPath (com.enonic.xp.content.ContentPath)1 CreateContentParams (com.enonic.xp.content.CreateContentParams)1 Property (com.enonic.xp.data.Property)1 FormItemSet (com.enonic.xp.form.FormItemSet)1 ContentType (com.enonic.xp.schema.content.ContentType)1 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)1 XData (com.enonic.xp.schema.xdata.XData)1