use of com.enonic.xp.form.Form in project xp by enonic.
the class HtmlAreaContentProcessorTest method page_config_data.
@Test
public void page_config_data() throws IOException {
final PropertyTree data = new PropertyTree();
data.addProperty("htmlData", ValueFactory.newString("<img data-src=\"image://image-id\"/>"));
final Form form = Form.create().addFormItem(Input.create().name("htmlData").label("htmlData").inputType(InputTypeName.HTML_AREA).build()).build();
final PageDescriptor pageDescriptor = PageDescriptor.create().config(form).regions(RegionDescriptors.create().build()).key(DescriptorKey.from("aaa:bbb")).build();
Mockito.when(pageDescriptorService.getByKey(Mockito.isA(DescriptorKey.class))).thenReturn(pageDescriptor);
final Page page = Page.create().config(data).descriptor(pageDescriptor.getKey()).build();
final EditableContent editableContent = new EditableContent(Media.create().name("myContentName").type(contentTypeName).page(page).parentPath(ContentPath.ROOT).data(new PropertyTree()).build());
result.getEditor().edit(editableContent);
assertEquals(1, editableContent.processedReferences.build().getSize());
assertTrue(editableContent.processedReferences.build().contains(ContentId.from("image-id")));
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class XmlXDataParser method doParse.
@Override
protected void doParse(final DomElement root) throws Exception {
assertTagName(root, "x-data");
this.builder.displayName(root.getChildValueTrimmed("display-name"));
this.builder.displayNameI18nKey(root.getChild("display-name") != null ? root.getChild("display-name").getAttribute("i18n") : null);
this.builder.description(root.getChildValue("description"));
this.builder.descriptionI18nKey(root.getChild("description") != null ? root.getChild("description").getAttribute("i18n") : null);
final XmlFormMapper mapper = new XmlFormMapper(this.currentApplication);
final Form form = mapper.buildForm(root.getChild("form"));
this.builder.form(form);
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class MacroDescriptorTest method testCreate.
@Test
public void testCreate() {
FieldSet body = FieldSet.create().label("Body").name("body").addFormItem(Input.create().name("param1").label("Parameter 1").inputType(InputTypeName.TEXT_LINE).build()).build();
final Form config = Form.create().addFormItem(body).build();
final MacroDescriptor macroDescriptor1 = MacroDescriptor.create().key(MacroKey.from("my-app:macro1")).description("my description").displayName("my display name").form(config).icon(Icon.from(new byte[] { 123 }, "image/png", Instant.now())).build();
assertEquals("my-app:macro1", macroDescriptor1.getKey().toString());
assertEquals("macro1", macroDescriptor1.getName());
assertEquals("my display name", macroDescriptor1.getDisplayName());
assertEquals("my description", macroDescriptor1.getDescription());
assertEquals(config, macroDescriptor1.getForm());
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class SiteDescriptorTest method create_site_descriptor.
@Test
public void create_site_descriptor() {
// Builds a Form
final FormItem formItem = Input.create().name("input").label("Input").inputType(InputTypeName.DOUBLE).build();
final Form form = Form.create().addFormItem(formItem).build();
// Builds MixinNames
List<XDataMapping> xDataMappingList = new ArrayList<>();
xDataMappingList.add(XDataMapping.create().xDataName(XDataName.from("myapplication:my")).build());
XDataMappings xDataMappings = XDataMappings.from(xDataMappingList);
// Builds a SiteDescriptor
SiteDescriptor siteDescriptor = SiteDescriptor.create().form(form).xDataMappings(xDataMappings).build();
assertEquals(form, siteDescriptor.getForm());
assertEquals(xDataMappings, siteDescriptor.getXDataMappings());
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class TaskDescriptorTest method testDescriptor.
@Test
public void testDescriptor() {
final DescriptorKey key = DescriptorKey.from(ApplicationKey.SYSTEM, "test");
final Form form = Form.create().build();
final TaskDescriptor descriptor = TaskDescriptor.create().key(key).description("test").config(form).build();
assertSame(key, descriptor.getKey());
assertEquals("test", descriptor.getDescription());
assertSame(form, descriptor.getConfig());
}
Aggregations