use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class ModifyContentHandlerTest method modifySiteConfig.
@Test
public void modifySiteConfig() {
final Content content = TestDataFixtures.newSmallContent();
when(this.contentService.getByPath(content.getPath())).thenReturn(content);
when(this.contentService.update(Mockito.isA(UpdateContentParams.class))).thenAnswer(invocationOnMock -> invokeUpdate((UpdateContentParams) invocationOnMock.getArguments()[0], TestDataFixtures.newSmallContent()));
mockXData();
final SiteDescriptor siteDescriptor1 = SiteDescriptor.create().form(Form.create().addFormItem(Input.create().label("a").name("a").inputType(InputTypeName.TEXT_LINE).build()).addFormItem(Input.create().label("b").name("b").inputType(InputTypeName.CHECK_BOX).build()).build()).build();
final SiteDescriptor siteDescriptor2 = SiteDescriptor.create().form(Form.create().addFormItem(Input.create().label("c").name("c").inputType(InputTypeName.LONG).build()).build()).build();
when(this.siteService.getDescriptor(ApplicationKey.from("appKey1"))).thenReturn(siteDescriptor1);
when(this.siteService.getDescriptor(ApplicationKey.from("appKey2"))).thenReturn(siteDescriptor2);
runFunction("/test/ModifyContentHandlerTest.js", "modifySiteConfig");
runFunction("/test/ModifyContentHandlerTest.js", "modifySiteConfig_strict");
}
use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class ModifyContentHandlerTest method modifySiteSingleDescriptor.
@Test
public void modifySiteSingleDescriptor() {
final Content content = TestDataFixtures.newSmallContent();
when(this.contentService.getByPath(content.getPath())).thenReturn(content);
when(this.contentService.update(Mockito.isA(UpdateContentParams.class))).thenAnswer(invocationOnMock -> invokeUpdate((UpdateContentParams) invocationOnMock.getArguments()[0], TestDataFixtures.newSmallContent()));
mockXData();
final SiteDescriptor siteDescriptor1 = SiteDescriptor.create().form(Form.create().addFormItem(Input.create().label("a").name("a").inputType(InputTypeName.TEXT_LINE).build()).addFormItem(Input.create().label("b").name("b").inputType(InputTypeName.CHECK_BOX).build()).build()).build();
when(this.siteService.getDescriptor(ApplicationKey.from("appKey1"))).thenReturn(siteDescriptor1);
runFunction("/test/ModifyContentHandlerTest.js", "modifySiteSingleDescriptor");
}
use of com.enonic.xp.site.SiteDescriptor in project xp by enonic.
the class HtmlAreaContentProcessor method processSiteConfigData.
private void processSiteConfigData(final SiteConfigs siteConfigs, final ContentIds.Builder processedIds) {
siteConfigs.forEach(siteConfig -> {
final SiteDescriptor siteDescriptor = siteService.getDescriptor(siteConfig.getApplicationKey());
if (siteDescriptor == null) {
return;
}
final Collection<Property> properties = getProperties(siteConfig.getConfig(), siteDescriptor.getForm().getFormItems());
processDataTree(properties, processedIds);
});
}
use of com.enonic.xp.site.SiteDescriptor 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.SiteDescriptor in project xp by enonic.
the class ControllerMappingsResolverTest method testResolveWithParameters.
@Test
public void testResolveWithParameters() {
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("key", "123", "category", "foo"), content, site.getSiteConfigs());
assertThat(mapping).map(ControllerMappingDescriptor::getController).map(ResourceKey::getPath).contains("/other/controller1.js");
}
Aggregations