Search in sources :

Example 11 with DescriptorKey

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());
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey) AdminToolDescriptor(com.enonic.xp.admin.tool.AdminToolDescriptor) Test(org.junit.jupiter.api.Test)

Example 12 with DescriptorKey

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());
}
Also used : Resource(com.enonic.xp.resource.Resource) DescriptorKey(com.enonic.xp.page.DescriptorKey) WidgetDescriptor(com.enonic.xp.admin.widget.WidgetDescriptor) ResourceKey(com.enonic.xp.resource.ResourceKey) Test(org.junit.jupiter.api.Test)

Example 13 with DescriptorKey

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;
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) PropertyTree(com.enonic.xp.data.PropertyTree) DescriptorKey(com.enonic.xp.page.DescriptorKey) Region(com.enonic.xp.region.Region) Page(com.enonic.xp.page.Page)

Example 14 with DescriptorKey

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();
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey) Region(com.enonic.xp.region.Region) LayoutRegions(com.enonic.xp.region.LayoutRegions)

Example 15 with DescriptorKey

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()));
}
Also used : PartDescriptor(com.enonic.xp.region.PartDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test) AbstractDescriptorServiceTest(com.enonic.xp.core.impl.content.page.AbstractDescriptorServiceTest)

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