use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class ControllerMappingsResolverTest method testResolvePatternWithParametersNoMatch.
@Test
public void testResolvePatternWithParametersNoMatch() {
final Content content = newContent();
final Site site = newSite();
final SiteDescriptor siteDescriptor = newSiteDescriptor3();
Mockito.when(this.siteService.getDescriptor(getAppKey2())).thenReturn(siteDescriptor);
final ControllerMappingsResolver resolver = new ControllerMappingsResolver(this.siteService);
final Optional<ControllerMappingDescriptor> mapping = resolver.resolve("/api", ImmutableMultimap.of(), content, site.getSiteConfigs());
assertTrue(mapping.isEmpty());
}
use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class ControllerMappingsResolverTest method testPatternCatchAllType_not_matches_missing.
@Test
public void testPatternCatchAllType_not_matches_missing() {
final ControllerMappingDescriptor mapping1 = ControllerMappingDescriptor.create().controller(ResourceKey.from(getAppKey2(), "/other/controller1.js")).contentConstraint("type:'.+:.+'").order(10).build();
final ControllerMappingDescriptors mappings = ControllerMappingDescriptors.from(mapping1);
final Site site = newSite();
final SiteDescriptor siteDescriptor = SiteDescriptor.create().mappingDescriptors(mappings).build();
Mockito.when(this.siteService.getDescriptor(getAppKey2())).thenReturn(siteDescriptor);
final ControllerMappingsResolver resolver = new ControllerMappingsResolver(this.siteService);
final Optional<ControllerMappingDescriptor> mapping = resolver.resolve("/does-not-exist", ImmutableMultimap.of(), null, site.getSiteConfigs());
assertTrue(mapping.isEmpty());
}
use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class XmlSiteParserTest method testSiteXmlWithUtf16BeBomEncoding.
@Test
public void testSiteXmlWithUtf16BeBomEncoding() {
final String xml = loadTestFile("utf16bebom.xml", StandardCharsets.UTF_16BE);
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(1, siteDescriptor.getForm().getFormItems().size());
assertEquals(2, siteDescriptor.getXDataMappings().getSize());
assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class XmlSiteParserTest method testSiteXmlDeserializationWithMappingFilters.
@Test
public void testSiteXmlDeserializationWithMappingFilters() {
final String xml = loadTestXml("serialized-site-with-mapping-filters.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(2, siteDescriptor.getMappingDescriptors().getSize());
final ControllerMappingDescriptor mapping1 = siteDescriptor.getMappingDescriptors().get(0);
final ControllerMappingDescriptor mapping2 = siteDescriptor.getMappingDescriptors().get(1);
assertEquals("myapplication:/filter1.js", mapping1.getFilter().toString());
assertEquals("_path:'/*/fisk'", mapping1.getContentConstraint().toString());
assertEquals("/.*", mapping1.getPattern().toString());
assertEquals(50, mapping1.getOrder());
assertEquals("myapplication:/filter2.js", mapping2.getFilter().toString());
assertEquals("type:'portal:fragment'", mapping2.getContentConstraint().toString());
assertEquals("/.*", mapping2.getPattern().toString());
assertEquals(5, mapping2.getOrder());
}
use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class XmlSiteParserTest method testSiteXmlWithUtf8BomEncoding.
@Test
public void testSiteXmlWithUtf8BomEncoding() {
final String xml = loadTestFile("utf8bom.xml", StandardCharsets.UTF_8);
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(1, siteDescriptor.getForm().getFormItems().size());
assertEquals(2, siteDescriptor.getXDataMappings().getSize());
assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
Aggregations