use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class AdminToolDescriptorServiceImplTest method getByKey.
@Test
public void getByKey() {
final DescriptorKey descriptorKey = DescriptorKey.from(ApplicationKey.from("myapp1"), "myadmintool");
final AdminToolDescriptor result = this.service.getByKey(descriptorKey);
assertNotNull(result);
assertEquals("My admin tool", result.getDisplayName());
assertEquals("My admin tool description", result.getDescription());
assertEquals(1, result.getAllowedPrincipals().getSize());
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class WidgetDescriptorLoaderTest method testLoadMin.
@Test
public void testLoadMin() {
final DescriptorKey descriptorKey = DescriptorKey.from("myapp1:widget2");
final ResourceKey resourceKey = this.loader.toResource(descriptorKey);
final Resource resource = this.resourceService.getResource(resourceKey);
final WidgetDescriptor descriptor = this.loader.load(descriptorKey, resource);
assertEquals("MyWidget2", descriptor.getDisplayName());
assertEquals("MyWidget2 description", descriptor.getDescription());
assertEquals(1, descriptor.getInterfaces().size());
assertTrue(descriptor.getInterfaces().contains("com.enonic.xp.my-interface"));
assertNull(descriptor.getAllowedPrincipals());
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class PageDataSerializerTest method createPage.
private Page createPage() {
final PropertyTree myPartConfig = new PropertyTree();
myPartConfig.addString("some", "somevalue");
final PropertyTree imageConfig = new PropertyTree();
imageConfig.addString("caption", "Caption");
final DescriptorKey pageDescriptorKey = DescriptorKey.from("app-key:d-name");
final String regionName1 = "top";
final String regionName2 = "bottom";
final Region mainRegion1 = Region.create().name(regionName1).add(createPartComponent("MyPart1", "app-descriptor-x:name-x", myPartConfig)).add(createLayoutComponent()).add(LayoutComponent.create().build()).build();
final Region mainRegion2 = Region.create().name(regionName2).add(createPartComponent("MyPart2", "app-descriptor-y:name-y", myPartConfig)).add(createImageComponent("img-id-x", "Image Component", imageConfig)).add(ImageComponent.create().build()).build();
final PageRegions regions = PageRegions.create().add(mainRegion1).add(mainRegion2).build();
final PropertyTree pageConfig = new PropertyTree();
pageConfig.addString("some", "config");
pageConfig.addDouble("aim", 42.0);
final Page page = Page.create().config(pageConfig).descriptor(pageDescriptorKey).regions(regions).build();
Mockito.when(pageDescriptorService.getByKey(pageDescriptorKey)).thenReturn(PageDescriptor.create().config(Form.create().build()).key(pageDescriptorKey).regions(RegionDescriptors.create().add(RegionDescriptor.create().name(regionName1).build()).add(RegionDescriptor.create().name(regionName2).build()).build()).build());
return page;
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class PageDataSerializerTest method createLayoutComponent.
private LayoutComponent createLayoutComponent() {
final String layoutName = "MyLayout";
final DescriptorKey layoutDescriptorKey = DescriptorKey.from("layoutDescriptor:name");
final String regionName1 = "left";
final String regionName2 = "right";
final Region region1 = Region.create().name(regionName1).add(PartComponent.create().build()).add(TextComponent.create().text("text text text").build()).add(TextComponent.create().build()).build();
final Region region2 = Region.create().name(regionName2).add(createImageComponent("image-id", "Some Image", null)).add(createFragmentComponent("213sda-ss222", "My Fragment")).build();
final LayoutRegions layoutRegions = LayoutRegions.create().add(region1).add(region2).build();
Mockito.when(layoutDescriptorService.getByKey(layoutDescriptorKey)).thenReturn(LayoutDescriptor.create().key(layoutDescriptorKey).displayName(layoutName).config(Form.create().build()).regions(RegionDescriptors.create().add(RegionDescriptor.create().name(regionName1).build()).add(RegionDescriptor.create().name(regionName2).build()).build()).build());
return LayoutComponent.create().descriptor(layoutDescriptorKey).regions(layoutRegions).build();
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class PartDescriptorServiceTest method testGetByKey.
@Test
public void testGetByKey() throws Exception {
final DescriptorKey key = DescriptorKey.from("myapp1:mypart");
final PartDescriptor descriptor = this.service.getByKey(key);
assertNotNull(descriptor);
assertTrue(Instant.now().isAfter(descriptor.getModifiedTime()));
}
Aggregations