use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class XDataConfigProcessorTest method processForms.
private PatternIndexConfigDocument processForms(final Form... forms) {
final XDatas.Builder xDatasBuilder = XDatas.create();
for (int i = 0; i < forms.length; i++) {
xDatasBuilder.add(XData.create().form(forms[i]).name(XDataName.from("appName:localName" + i)).build());
}
final XDatas xDatas = xDatasBuilder.build();
final ContentType contentType = ContentType.create().superType(ContentTypeName.folder()).xData(XDataNames.from(xDatas.getNames())).name("contentType").build();
Mockito.when(contentTypeService.getByName(new GetContentTypeParams().contentTypeName(contentTypeName))).thenReturn(contentType);
Mockito.when(xDataService.getFromContentType(contentType)).thenReturn(xDatasBuilder.build());
final XDataConfigProcessor configProcessor = new XDataConfigProcessor(xDatas);
return configProcessor.processDocument(PatternIndexConfigDocument.create()).build();
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class OccurrenceValidatorTest method testOptionSetWithUnlimitedNumberAllowedSelections.
@Test
public void testOptionSetWithUnlimitedNumberAllowedSelections() {
Form form = Form.create().addFormItem(FormOptionSet.create().name("options").label("Option tests").multiselection(Occurrences.create(0, 0)).occurrences(Occurrences.create(1, 1)).addOptionSetOption(FormOptionSetOption.create().name("a").label("A").build()).addOptionSetOption(FormOptionSetOption.create().name("b").label("B").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();
PropertySet propertySet = new PropertySet();
propertySet.setProperty("a", ValueFactory.newString("Value A"));
propertySet.setProperty("b", ValueFactory.newString("Value B"));
content.getData().setSet("options", propertySet);
final ValidationErrors validationResults = validate(content);
assertFalse(validationResults.hasErrors());
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class OccurrenceValidatorTest method testOptionSetWithUnlimitedNumberAllowedSelectionsAndDefaultValues.
@Test
public void testOptionSetWithUnlimitedNumberAllowedSelectionsAndDefaultValues() {
ContentType contentType = ContentType.create().name("myapplication:my_type").superType(ContentTypeName.structured()).form(Form.create().addFormItem(FormOptionSet.create().name("options").label("Option tests").multiselection(Occurrences.create(0, 0)).occurrences(Occurrences.create(1, 1)).addOptionSetOption(FormOptionSetOption.create().name("a").label("A").build()).addOptionSetOption(FormOptionSetOption.create().name("b").label("B").defaultOption(true).build()).build()).build()).build();
Content content = Content.create().path(MY_CONTENT_PATH).type(contentType.getName()).build();
content.getData().setSet("options", 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 InputValidatorTest method before.
@BeforeEach
public void before() {
final ContentType contentType = createContentTypeForAllInputTypes(ContentTypeName.audioMedia());
this.inputValidator = InputValidator.create().form(contentType.getForm()).inputTypeResolver(InputTypes.BUILTIN).build();
}
use of com.enonic.xp.schema.content.ContentType in project xp by enonic.
the class AbstractCommand method doTransformInlineMixins.
private ContentTypes doTransformInlineMixins(final ContentTypes contentTypes) {
final ContentTypes.Builder transformedContentTypes = ContentTypes.create();
for (final ContentType contentType : contentTypes) {
final Form transformedForm = mixinService.inlineFormItems(contentType.getForm());
final ContentType transformedCty = ContentType.create(contentType).form(transformedForm).build();
transformedContentTypes.add(transformedCty);
}
return transformedContentTypes.build();
}
Aggregations