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);
}
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();
}
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);
}
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);
}
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);
}
}
Aggregations