use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class XmlContentTypeParserTest method testI18n_optionSet.
@Test
public void testI18n_optionSet() throws Exception {
parse(this.parser, "-i18n.xml");
final ContentType result = this.builder.build();
final FormItem item = result.getForm().getFormItem("radioOptionSet");
assertNotNull(item);
final FormOptionSet radioOptionSet = (FormOptionSet) item;
assertEquals(FormItemType.FORM_OPTION_SET, radioOptionSet.getType());
assertEquals("translated.help-text", radioOptionSet.getHelpTextI18nKey());
assertEquals("translated.label", radioOptionSet.getLabelI18nKey());
final Input inputInsideOption = radioOptionSet.getFormItems().getInput(FormItemPath.from("option_1.text-input"));
assertEquals("translated.help-text", inputInsideOption.getHelpTextI18nKey());
assertEquals("translated.label", inputInsideOption.getLabelI18nKey());
final FormOptionSetOption radioOption = radioOptionSet.getFormItems().getItemByName("option_1").toFormOptionSetOption();
assertEquals("translated.help-text", radioOption.getHelpTextI18nKey());
assertEquals("translated.label", radioOption.getLabelI18nKey());
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class XmlContentTypeParserTest method testMixinRefFormats.
@Test
public void testMixinRefFormats() throws Exception {
parse(this.parser, "-mixins.xml");
final ContentType result = this.builder.build();
final XDataNames xDataNames = result.getXData();
assertEquals(2, xDataNames.getSize());
assertTrue(xDataNames.contains(XDataName.from("myapplication:metadata1")));
assertTrue(xDataNames.contains(XDataName.from("myapplication:metadata2")));
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class OccurrenceValidatorTest method testOptionSetWithDefaultValue.
@Test
public void testOptionSetWithDefaultValue() {
Form form = Form.create().addFormItem(FormOptionSet.create().name("checkOptionSet").label("Multi selection").expanded(true).helpText("Help Text").multiple(true).multiselection(Occurrences.create(1, 3)).occurrences(Occurrences.create(1, 1)).addOptionSetOption(FormOptionSetOption.create().name("option_1").label("option_1").helpText("Help text for Option_1").build()).addOptionSetOption(FormOptionSetOption.create().name("option_2").label("option_2").helpText("Help text for Option_2").build()).addOptionSetOption(FormOptionSetOption.create().name("option_3").label("option_3").defaultOption(true).helpText("Help text for Option_3").addFormItem(Input.create().name("htmlAreaField").label("Input").inputType(InputTypeName.HTML_AREA).occurrences(Occurrences.create(2, 4)).build()).build()).build()).build();
ContentType contentType = ContentType.create().name("myapplication:my_type").superType(ContentTypeName.structured()).form(form).build();
Content content = Content.create().path(MY_CONTENT_PATH).type(contentType.getName()).build();
content.getData().setSet("checkOptionSet.option_3", new PropertySet());
final ValidationErrors validationResults = validate(content);
assertFalse(validationResults.hasErrors());
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class ContentServiceImplTest_publish method push_one_content_not_valid.
@Disabled
@Test
public void push_one_content_not_valid() throws Exception {
ContentType contentType = ContentType.create().superType(ContentTypeName.structured()).name("myapplication:test").addFormItem(Input.create().name("title").label("Title").inputType(InputTypeName.TEXT_LINE).required(true).build()).build();
Mockito.when(this.contentTypeService.getByName(GetContentTypeParams.from(contentType.getName()))).thenReturn(contentType);
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(contentType.getName()).build();
final Content content = this.contentService.create(createContentParams);
final PublishContentResult push = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).build());
assertEquals(1, push.getPushedContents().getSize());
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class ContentTypeHandler method getContentType.
public ContentTypeMapper getContentType() {
if (name == null || name.isBlank()) {
return null;
}
final GetContentTypeParams params = GetContentTypeParams.from(ContentTypeName.from(name));
final ContentType ctype = contentTypeService.get().getByName(params);
return ctype == null ? null : new ContentTypeMapper(inlineMixins(ctype));
}
Aggregations