use of com.enonic.xp.form.Form in project xp by enonic.
the class AbstractContentSynchronizerTest method setUpContentService.
private void setUpContentService() {
final Map<String, List<String>> metadata = new HashMap<>();
metadata.put(HttpHeaders.CONTENT_TYPE, List.of("image/jpg"));
final ExtractedData extractedData = ExtractedData.create().metadata(metadata).build();
final BinaryExtractor extractor = mock(BinaryExtractor.class);
when(extractor.extract(isA(ByteSource.class))).thenReturn(extractedData);
mediaInfoService = new MediaInfoServiceImpl();
mediaInfoService.setBinaryExtractor(extractor);
XDataService xDataService = mock(XDataService.class);
MixinService mixinService = mock(MixinService.class);
when(mixinService.inlineFormItems(isA(Form.class))).then(AdditionalAnswers.returnsFirstArg());
pageDescriptorService = mock(PageDescriptorService.class);
partDescriptorService = mock(PartDescriptorService.class);
layoutDescriptorService = mock(LayoutDescriptorService.class);
contentTypeService = new ContentTypeServiceImpl(null, null, mixinService);
final ResourceService resourceService = mock(ResourceService.class);
final SiteServiceImpl siteService = new SiteServiceImpl();
siteService.setResourceService(resourceService);
siteService.setMixinService(mixinService);
final AuditLogService auditLogService = mock(AuditLogService.class);
final ContentConfig contentConfig = mock(ContentConfig.class);
final ContentAuditLogSupportImpl contentAuditLogSupport = new ContentAuditLogSupportImpl(contentConfig, new ContentAuditLogExecutorImpl(), auditLogService);
contentService = new ContentServiceImpl(nodeService, pageDescriptorService, partDescriptorService, layoutDescriptorService);
contentService.setEventPublisher(eventPublisher);
contentService.setMediaInfoService(mediaInfoService);
contentService.setSiteService(siteService);
contentService.setContentTypeService(contentTypeService);
contentService.setxDataService(xDataService);
contentService.setFormDefaultValuesProcessor((form, data) -> {
});
contentService.setContentAuditLogSupport(contentAuditLogSupport);
contentService.initialize(mock(ContentConfig.class, invocation -> invocation.getMethod().getDefaultValue()));
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class DescriptorsTest method partDescriptor.
@Test
public void partDescriptor() {
final Form partForm = Form.create().addFormItem(Input.create().name("width").label("width").inputType(InputTypeName.DOUBLE).build()).build();
final PartDescriptor partDescriptor = PartDescriptor.create().displayName("News part").config(partForm).key(DescriptorKey.from("module:new-part")).build();
final PartDescriptor copy = PartDescriptor.copyOf(partDescriptor).build();
assertEquals("News part", partDescriptor.getDisplayName());
assertEquals(partDescriptor.getComponentPath(), copy.getComponentPath());
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class DescriptorsTest method layoutDescriptor.
@Test
public void layoutDescriptor() {
final Form layoutForm = Form.create().addFormItem(Input.create().name("columns").label("columns").inputType(InputTypeName.DOUBLE).build()).build();
final LayoutDescriptor layoutDescriptor = LayoutDescriptor.create().displayName("Fancy layout").config(layoutForm).regions(RegionDescriptors.create().build()).key(DescriptorKey.from("module:fancy-layout")).build();
final LayoutDescriptor copy = LayoutDescriptor.copyOf(layoutDescriptor).build();
assertEquals("Fancy layout", layoutDescriptor.getDisplayName());
assertEquals(layoutForm, layoutDescriptor.getConfig());
assertEquals(layoutDescriptor.getComponentPath(), copy.getComponentPath());
assertEquals(layoutDescriptor.getRegions(), copy.getRegions());
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class DescriptorsTest method pageDescriptor.
@Test
public void pageDescriptor() {
final Form pageForm = Form.create().addFormItem(Input.create().name("pause").label("pause").inputType(InputTypeName.DOUBLE).build()).build();
final PageDescriptor pageDescriptor = PageDescriptor.create().displayName("Landing page").config(pageForm).regions(RegionDescriptors.create().build()).key(DescriptorKey.from("module:landing-page")).build();
assertEquals("Landing page", pageDescriptor.getDisplayName());
assertEquals("landing-page", pageDescriptor.getName());
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class PageDescriptorsTest method from.
@Test
public void from() {
final Form pageForm = Form.create().addFormItem(Input.create().name("pause").label("pause").inputType(InputTypeName.DOUBLE).build()).build();
final PageDescriptor pageDescriptor1 = PageDescriptor.create().displayName("Landing page").config(pageForm).regions(RegionDescriptors.create().build()).key(DescriptorKey.from("module:landing-page")).build();
final PageDescriptor pageDescriptor2 = PageDescriptor.create().displayName("Log out").config(pageForm).regions(RegionDescriptors.create().build()).key(DescriptorKey.from("module:logout-page")).build();
final PageDescriptor pageDescriptor3 = PageDescriptor.copyOf(pageDescriptor1).build();
assertEquals(3, PageDescriptors.from(pageDescriptor1, pageDescriptor2, pageDescriptor3).getSize());
assertEquals(3, PageDescriptors.from(Arrays.asList(pageDescriptor1, pageDescriptor2, pageDescriptor3)).getSize());
}
Aggregations