use of com.enonic.xp.site.mapping.ControllerMappingDescriptors in project xp by enonic.
the class ControllerMappingsResolverTest method newDescriptorForFragments.
private SiteDescriptor newDescriptorForFragments() {
final ControllerMappingDescriptor mapping1 = ControllerMappingDescriptor.create().controller(ResourceKey.from(getAppKey(), "/site/controllers/controller1.js")).pattern("/.*").contentConstraint("type:'portal:fragment'").order(10).build();
final ControllerMappingDescriptors mappings = ControllerMappingDescriptors.from(mapping1);
return SiteDescriptor.create().mappingDescriptors(mappings).build();
}
use of com.enonic.xp.site.mapping.ControllerMappingDescriptors in project xp by enonic.
the class ControllerMappingsResolverTest method newSiteDescriptor3.
private SiteDescriptor newSiteDescriptor3() {
final ControllerMappingDescriptor mapping1 = ControllerMappingDescriptor.create().controller(ResourceKey.from(getAppKey2(), "/other/controller1.js")).pattern("/.*api.*\\?category=.*&key=\\d+").order(10).build();
final ControllerMappingDescriptors mappings = ControllerMappingDescriptors.from(mapping1);
return SiteDescriptor.create().mappingDescriptors(mappings).build();
}
use of com.enonic.xp.site.mapping.ControllerMappingDescriptors 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.mapping.ControllerMappingDescriptors in project xp by enonic.
the class MappingHandlerTest method setupContentAndSite.
private void setupContentAndSite(final ControllerMappingDescriptor mapping) {
final Content content = createPage("id", "site/somesite/content", "myapplication:ctype", true);
final Site site = createSite("id", "site", "myapplication:contenttypename");
final ContentPath path = ContentPath.from("site/somesite/content").asAbsolute();
when(this.contentService.getByPath(path)).thenReturn(content);
when(this.contentService.findNearestSiteByPath(eq(path))).thenReturn(site);
when(this.contentService.getById(content.getId())).thenReturn(content);
final ControllerMappingDescriptors mappings = ControllerMappingDescriptors.from(mapping);
final SiteDescriptor siteDescriptor = SiteDescriptor.create().mappingDescriptors(mappings).build();
when(this.siteService.getDescriptor(any(ApplicationKey.class))).thenReturn(siteDescriptor);
}
use of com.enonic.xp.site.mapping.ControllerMappingDescriptors in project xp by enonic.
the class ControllerMappingsResolverTest method newSiteDescriptor.
private SiteDescriptor newSiteDescriptor() {
final ControllerMappingDescriptor mapping1 = ControllerMappingDescriptor.create().controller(ResourceKey.from(getAppKey(), "/site/controllers/controller1.js")).pattern("/.*").contentConstraint("_id:'123456'").order(10).build();
final ControllerMappingDescriptor mapping2 = ControllerMappingDescriptor.create().controller(ResourceKey.from(getAppKey(), "/site/controllers/controller2.js")).pattern("/.*").contentConstraint("_path:'/mysite/landing-page'").order(5).build();
final ControllerMappingDescriptor mapping3 = ControllerMappingDescriptor.create().controller(ResourceKey.from(getAppKey(), "/site/controllers/controller3.js")).pattern("/.*").contentConstraint("_name:'landing-page'").order(15).build();
final ControllerMappingDescriptors mappings = ControllerMappingDescriptors.from(mapping1, mapping2, mapping3);
return SiteDescriptor.create().mappingDescriptors(mappings).build();
}
Aggregations