use of com.enonic.xp.admin.widget.WidgetDescriptor in project xp by enonic.
the class WidgetDescriptorServiceTest method get_allowed_by_interfaces_as_admin.
@Test
public void get_allowed_by_interfaces_as_admin() throws Exception {
final AuthenticationInfo authenticationInfo = AuthenticationInfo.copyOf(ContextAccessor.current().getAuthInfo()).principals(PrincipalKey.ofRole("system.admin")).build();
final Context adminContext = ContextBuilder.from(ContextAccessor.current()).authInfo(authenticationInfo).build();
adminContext.runWith(() -> {
final Descriptors<WidgetDescriptor> result = this.service.getAllowedByInterfaces("com.enonic.xp.my-interface");
assertEquals(4, result.getSize());
assertTrue(result.contains(widgetDescriptor1));
assertTrue(result.contains(widgetDescriptor3));
assertTrue(result.contains(widgetDescriptor4));
assertTrue(result.contains(widgetDescriptor5));
});
}
use of com.enonic.xp.admin.widget.WidgetDescriptor in project xp by enonic.
the class WidgetDescriptorLoaderTest method testCreateDefault.
@Test
public void testCreateDefault() {
final DescriptorKey key = DescriptorKey.from("myapp1:widget1");
final WidgetDescriptor descriptor = this.loader.createDefault(key);
assertEquals(key, descriptor.getKey());
assertEquals("widget1", descriptor.getName());
}
use of com.enonic.xp.admin.widget.WidgetDescriptor in project xp by enonic.
the class WidgetDescriptorLoaderTest method testLoadMax.
@Test
public void testLoadMax() {
final DescriptorKey descriptorKey = DescriptorKey.from("myapp1:widget1");
final ResourceKey resourceKey = this.loader.toResource(descriptorKey);
assertEquals("myapp1:/admin/widgets/widget1/widget1.xml", resourceKey.toString());
final Resource resource = this.resourceService.getResource(resourceKey);
final WidgetDescriptor descriptor = this.loader.load(descriptorKey, resource);
assertEquals("MyWidget", descriptor.getDisplayName());
assertEquals(1, descriptor.getInterfaces().size());
assertTrue(descriptor.getInterfaces().contains("com.enonic.xp.my-interface"));
assertEquals(1, descriptor.getAllowedPrincipals().getSize());
assertTrue(descriptor.getAllowedPrincipals().contains(PrincipalKey.from("role:system.user.admin")));
}
use of com.enonic.xp.admin.widget.WidgetDescriptor in project xp by enonic.
the class XmlWidgetDescriptorParserTest method assertResult.
private void assertResult() throws Exception {
final WidgetDescriptor result = this.builder.build();
assertEquals("myapplication:mywidget", result.getKey().toString());
assertEquals("mywidget", result.getName());
assertEquals("My widget", result.getDisplayName());
assertEquals("My widget description", result.getDescription());
assertEquals("myapplication:mywidget", result.getKeyString());
assertEquals("_/widgets/myapplication/mywidget", result.getUrl());
final Set<String> interfaces = result.getInterfaces();
assertNotNull(interfaces);
assertEquals(2, interfaces.size());
final Map<String, String> config = result.getConfig();
assertNotNull(config);
assertEquals(2, config.size());
}
use of com.enonic.xp.admin.widget.WidgetDescriptor in project xp by enonic.
the class WidgetDescriptorServiceTest method get_by_key.
@Test
public void get_by_key() throws Exception {
final WidgetDescriptor allowedWidget = this.service.getByKey(DescriptorKey.from("app:d"));
assertSame(allowedWidget, widgetDescriptor4);
final WidgetDescriptor unknownWidget = this.service.getByKey(DescriptorKey.from("app:unknown"));
assertNull(unknownWidget);
}
Aggregations