Search in sources :

Example 46 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class PageDescriptorServiceTest method testGetByKey.

@Test
public void testGetByKey() throws Exception {
    final DescriptorKey key = DescriptorKey.from("myapp1:mypage");
    final PageDescriptor descriptor = this.service.getByKey(key);
    assertNotNull(descriptor);
}
Also used : PageDescriptor(com.enonic.xp.page.PageDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test)

Example 47 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class CreateFragmentCommandTest method testLayoutComponentName.

private String testLayoutComponentName(final String name) {
    final ArgumentCaptor<CreateContentParams> captor = captorFragmentCreation();
    final DescriptorKey layoutKey = DescriptorKey.from(ApplicationKey.from("application"), "layout1");
    Mockito.when(this.layoutDescriptorService.getByKey(layoutKey)).thenReturn(layoutDescriptor(layoutKey, name));
    createFragmentCommand(createFragmentParams(layoutComponent(layoutKey))).execute();
    return captor.getValue().getDisplayName();
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) DescriptorKey(com.enonic.xp.page.DescriptorKey)

Example 48 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class RegionDataSerializerTest method region.

@Test
public void region() {
    final PropertyTree myPartConfig = new PropertyTree();
    myPartConfig.addString("some", "config");
    final String layoutName = "MyOtherPart";
    final DescriptorKey layoutDescriptorKey = DescriptorKey.from("app-descr:layout-name");
    final Region region = Region.create().name("main").add(createPartComponent("MyPart", "app-descr:part-name", myPartConfig)).add(ImageComponent.create().build()).add(LayoutComponent.create().descriptor(layoutDescriptorKey).build()).build();
    Mockito.when(layoutDescriptorService.getByKey(layoutDescriptorKey)).thenReturn(LayoutDescriptor.create().key(layoutDescriptorKey).displayName(layoutName).config(Form.create().build()).regions(RegionDescriptors.create().build()).build());
    final PropertyTree regionAsData = new PropertyTree();
    // exercise
    regionSerializer.toData(region, regionAsData.getRoot());
    final RegionDescriptor regionDescriptor = RegionDescriptor.create().name("main").build();
    final List<PropertySet> components = regionAsData.getProperties(ComponentDataSerializer.COMPONENTS).stream().map(item -> item.getSet()).collect(Collectors.toList());
    final Region parsedRegion = regionSerializer.fromData(regionDescriptor, ComponentPath.DIVIDER, components);
    // verify
    assertEquals(region, parsedRegion);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) PropertySet(com.enonic.xp.data.PropertySet) RegionDescriptors(com.enonic.xp.region.RegionDescriptors) Collectors(java.util.stream.Collectors) ComponentPath(com.enonic.xp.region.ComponentPath) LayoutDescriptor(com.enonic.xp.region.LayoutDescriptor) Test(org.junit.jupiter.api.Test) Form(com.enonic.xp.form.Form) Region(com.enonic.xp.region.Region) Mockito(org.mockito.Mockito) List(java.util.List) LayoutComponent(com.enonic.xp.region.LayoutComponent) DescriptorKey(com.enonic.xp.page.DescriptorKey) AbstractDataSerializerTest(com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest) ImageComponent(com.enonic.xp.region.ImageComponent) RegionDescriptor(com.enonic.xp.region.RegionDescriptor) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PropertyTree(com.enonic.xp.data.PropertyTree) RegionDescriptor(com.enonic.xp.region.RegionDescriptor) PropertyTree(com.enonic.xp.data.PropertyTree) DescriptorKey(com.enonic.xp.page.DescriptorKey) Region(com.enonic.xp.region.Region) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test) AbstractDataSerializerTest(com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest)

Example 49 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class MacroDescriptorServiceImpl method getByApplication.

@Override
public MacroDescriptors getByApplication(final ApplicationKey applicationKey) {
    final List<MacroDescriptor> list = new ArrayList<>();
    if (isSystem(applicationKey)) {
        list.addAll(builtinMacrosDescriptors.getAll().getSet());
    } else {
        for (final DescriptorKey descriptorKey : descriptorKeyLocator.findKeys(applicationKey)) {
            final MacroKey macroKey = MacroKey.from(descriptorKey.getApplicationKey(), descriptorKey.getName());
            final MacroDescriptor descriptor = getByKey(macroKey);
            if (descriptor != null) {
                list.add(descriptor);
            }
        }
    }
    return MacroDescriptors.from(list);
}
Also used : MacroKey(com.enonic.xp.macro.MacroKey) MacroDescriptor(com.enonic.xp.macro.MacroDescriptor) ArrayList(java.util.ArrayList) DescriptorKey(com.enonic.xp.page.DescriptorKey)

Example 50 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class FlattenedPageRegionsIndexUpgrader method upgradeDescriptorBasedComponent.

private void upgradeDescriptorBasedComponent(PropertySet componentSet, final String componentType) {
    final String descriptorKeyStr = componentSet.getString(TGT_DESCRIPTOR_KEY);
    if (descriptorKeyStr != null) {
        final DescriptorKey descriptorKey = DescriptorKey.from(descriptorKeyStr);
        result.add(String.join(ELEMENT_DIVIDER, TGT_COMPONENTS_KEY, componentType, TGT_CONFIG_KEY, getSanitizedAppName(descriptorKey), getSanitizedComponentName(descriptorKey), "*"), IndexConfig.BY_TYPE);
    }
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey)

Aggregations

DescriptorKey (com.enonic.xp.page.DescriptorKey)73 Test (org.junit.jupiter.api.Test)45 PropertyTree (com.enonic.xp.data.PropertyTree)25 PrincipalKey (com.enonic.xp.security.PrincipalKey)11 ScheduledJob (com.enonic.xp.scheduler.ScheduledJob)10 TaskId (com.enonic.xp.task.TaskId)10 Page (com.enonic.xp.page.Page)7 ScheduledJobName (com.enonic.xp.scheduler.ScheduledJobName)7 TaskDescriptor (com.enonic.xp.task.TaskDescriptor)7 Instant (java.time.Instant)7 PropertySet (com.enonic.xp.data.PropertySet)6 ServiceDescriptor (com.enonic.xp.service.ServiceDescriptor)6 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)5 CronCalendar (com.enonic.xp.scheduler.CronCalendar)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 ApplicationKey (com.enonic.xp.app.ApplicationKey)4 AbstractDescriptorServiceTest (com.enonic.xp.core.impl.content.page.AbstractDescriptorServiceTest)4 DescribedTask (com.enonic.xp.impl.task.distributed.DescribedTask)4 PortalRequest (com.enonic.xp.portal.PortalRequest)4 PortalResponse (com.enonic.xp.portal.PortalResponse)4