use of com.enonic.xp.site.mapping.ControllerMappingDescriptor in project xp by enonic.
the class ControllerMappingsResolverTest method testNoDescriptors.
@Test
public void testNoDescriptors() {
final Content content = newContent();
final Site site = newSite();
final ControllerMappingsResolver resolver = new ControllerMappingsResolver(this.siteService);
final Optional<ControllerMappingDescriptor> mapping = resolver.resolve("/landing-page", ImmutableMultimap.of(), content, site.getSiteConfigs());
assertTrue(mapping.isEmpty());
}
use of com.enonic.xp.site.mapping.ControllerMappingDescriptor 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.ControllerMappingDescriptor in project xp by enonic.
the class MappingHandlerTest method executeScript.
@Test
public void executeScript() throws Exception {
final ResourceKey controller = ResourceKey.from("demo:/services/test");
final ControllerMappingDescriptor mapping = ControllerMappingDescriptor.create().controller(controller).pattern(".*/content").build();
setupContentAndSite(mapping);
this.request.setBaseUri("/site");
this.request.setContentPath(ContentPath.from("/site/somesite/content"));
when(rendererDelegate.render(isA(ControllerMappingDescriptor.class), same(request))).thenReturn(PortalResponse.create().body("Ok").build());
final WebResponse response = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertEquals(HttpStatus.OK, response.getStatus());
assertNotNull(this.request.getApplicationKey());
assertNotNull(this.request.getSite());
assertNotNull(this.request.getContent());
}
use of com.enonic.xp.site.mapping.ControllerMappingDescriptor in project xp by enonic.
the class MappingHandlerTest method executeNothing.
@Test
public void executeNothing() throws Exception {
final ResourceKey controller = ResourceKey.from("demo:/services/test");
final ControllerMappingDescriptor mapping = ControllerMappingDescriptor.create().controller(controller).pattern("/nomatch").build();
setupContentAndSite(mapping);
final WebHandlerChain chain = mock(WebHandlerChain.class);
final PortalResponse response = PortalResponse.create().build();
this.request.setBaseUri("/site");
this.request.setContentPath(ContentPath.from("/site/somesite/content"));
this.handler.handle(this.request, response, chain);
verify(chain).handle(this.request, response);
verifyNoInteractions(rendererDelegate);
}
use of com.enonic.xp.site.mapping.ControllerMappingDescriptor 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();
}
Aggregations