Search in sources :

Example 16 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class ComboBoxTypeTest method testCreateDefaultValue.

@Test
public void testCreateDefaultValue() {
    final Input input = getDefaultInputBuilder(InputTypeName.COMBO_BOX, "testOption").build();
    final Value value = this.type.createDefaultValue(input);
    assertNotNull(value);
    assertEquals("testOption", value.toString());
}
Also used : Input(com.enonic.xp.form.Input) Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 17 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class HtmlStripperTest method processEscapedCharacters.

@Test
void processEscapedCharacters() {
    Value valueToProcess = ValueFactory.newString("<tag value=\"æøå\"/>");
    assertEquals(ValueFactory.newString("<tag value=\"æøå\"/>"), this.htmlStripper.process(valueToProcess));
    valueToProcess = ValueFactory.newXml("&lt;tag value=\"&aelig;&oslash;&aring;\"/&gt;");
    assertEquals(ValueFactory.newXml("<tag value=\"æøå\"/>"), this.htmlStripper.process(valueToProcess));
}
Also used : Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 18 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class DateTimeTypeTest method testCreateProperty_withTimezone.

@Test
public void testCreateProperty_withTimezone() {
    final InputTypeConfig config = newFullConfig();
    final Value value = this.type.createValue(ValueFactory.newString("2015-01-02T22:11:00Z"), config);
    assertNotNull(value);
    assertSame(ValueTypes.DATE_TIME, value.getType());
}
Also used : Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 19 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class DateTimeTypeTest method testCreateProperty.

@Test
public void testCreateProperty() {
    final InputTypeConfig config = newEmptyConfig();
    final Value value = this.type.createValue(ValueFactory.newString("2015-01-02T22:11:00"), config);
    assertNotNull(value);
    assertSame(ValueTypes.LOCAL_DATE_TIME, value.getType());
}
Also used : Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 20 with Value

use of com.enonic.xp.data.Value in project xp by enonic.

the class FormJsonToPropertyTreeTranslator method mapValue.

private void mapValue(final PropertySet parent, final String key, final JsonNode value) {
    final Property parentProperty = parent.getProperty();
    final Input input = getInput(parentProperty, key);
    if (input == null) {
        if (this.strictMode && !isOptionSetSelection(key, parentProperty)) {
            throw new IllegalArgumentException("No mapping defined for property " + key + " with value " + resolveStringValue(value));
        }
        parent.addProperty(key, resolveCoreValue(value));
    } else {
        final InputType type = this.inputTypeResolver.resolve(input.getInputType());
        final Value mappedPropertyValue = type.createValue(resolveCoreValue(value), input.getInputTypeConfig());
        parent.addProperty(key, mappedPropertyValue);
    }
}
Also used : Input(com.enonic.xp.form.Input) InputType(com.enonic.xp.inputtype.InputType) Value(com.enonic.xp.data.Value) Property(com.enonic.xp.data.Property)

Aggregations

Value (com.enonic.xp.data.Value)62 Test (org.junit.jupiter.api.Test)48 Input (com.enonic.xp.form.Input)24 Property (com.enonic.xp.data.Property)4 PropertySet (com.enonic.xp.data.PropertySet)4 PropertyTree (com.enonic.xp.data.PropertyTree)3 InputType (com.enonic.xp.inputtype.InputType)2 Instant (java.time.Instant)2 PropertyPath (com.enonic.xp.data.PropertyPath)1 FieldSet (com.enonic.xp.form.FieldSet)1 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)1 IndexConfig (com.enonic.xp.index.IndexConfig)1 IndexValueProcessor (com.enonic.xp.index.IndexValueProcessor)1 AttachedBinary (com.enonic.xp.node.AttachedBinary)1 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1 Node (com.enonic.xp.node.Node)1 NodePath (com.enonic.xp.node.NodePath)1 NodeQuery (com.enonic.xp.node.NodeQuery)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 NodeVersionQuery (com.enonic.xp.node.NodeVersionQuery)1